ExCEP.Cluster.Session (ex_cep v0.1.1)

Copy Markdown

Per-gateway TCP/TLS connection session on the Cluster (Master) server.

Executes the server side of Section 5 three-way SM2 authentication, registers the authenticated gateway_id with ExCEP.Cluster.Server, correlates Cluster -> Gateway requests by Head/Mid, and dispatches Gateway -> Cluster reports to ExCEP.Cluster.Handler.

Summary

Functions

Returns a specification to start this module under a supervisor.

Closes the session (idempotent if already stopped).

Pulls a file from the Gateway using Section 6.2.1 FileGet + FileDataTrans.

Sends a %DataAsdu{} request from the Cluster to this Gateway and awaits its response.

Sends a %DataAsdu{} from the Cluster to this Gateway without waiting for a response.

Starts an unlinked session process (used by ExCEP.Cluster.Server for fault isolation).

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(session)

@spec close(pid()) :: :ok

Closes the session (idempotent if already stopped).

pull_file(session, remote_path, opts \\ [])

@spec pull_file(pid(), String.t(), keyword()) :: {:ok, binary()} | {:error, term()}

Pulls a file from the Gateway using Section 6.2.1 FileGet + FileDataTrans.

request(session, asdu, opts \\ [])

@spec request(pid(), ExCEP.Codec.DataAsdu.t(), keyword()) ::
  {:ok, ExCEP.Codec.DataAsdu.t()} | {:error, term()}

Sends a %DataAsdu{} request from the Cluster to this Gateway and awaits its response.

send_asdu(session, asdu, opts \\ [])

@spec send_asdu(pid(), ExCEP.Codec.DataAsdu.t(), keyword()) :: :ok | {:error, term()}

Sends a %DataAsdu{} from the Cluster to this Gateway without waiting for a response.

start(opts)

@spec start(keyword()) :: GenServer.on_start()

Starts an unlinked session process (used by ExCEP.Cluster.Server for fault isolation).

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()