View Source Grizzly.Transport behaviour (grizzly v8.5.3)
Behaviour and functions for communicating to zipgateway
Summary
Types
After starting a server options can be passed back to the caller so that the caller can do any other work it might seem fit.
Functions
Accept a new connection
Get the assign value for the field
Update the assigns with this field and value
Preform the handshake
Listen using a transport
Make a new Grizzly.Transport
Open the transport
Parse the response for the transport
Send binary data using a transport
Types
@type args() :: [ ip_address: :inet.ip_address(), port: :inet.port_number(), node_id: Grizzly.node_id(), transport: t() ]
@type listen_option() :: {:strategy, :none | :accept}
After starting a server options can be passed back to the caller so that the caller can do any other work it might seem fit.
Options:
:strategy
- this informs the caller if the transport needs to wait for connects to accept or if the socket can just process incoming messages. If the strategy is:accept
that is to mean the socket is okay to start accepting new connections.
@type parse_opt() :: {:raw, boolean()}
@type socket() :: :ssl.sslsocket() | :inet.socket()
@opaque t()
Callbacks
@callback close(t()) :: :ok
@callback listen(t()) :: {:ok, t(), [listen_option()]} | {:error, any()}
@callback parse_response(any(), [parse_opt()]) :: {:ok, Grizzly.Transport.Response.t() | binary() | :connection_closed} | {:error, Grizzly.ZWave.DecodeError.t()}
@callback peername(t()) :: {:ok, {:inet.ip_address(), :inet.port_number()}} | {:error, any()}
Functions
Accept a new connection
Get the assign value for the field
Update the assigns with this field and value
Preform the handshake
@spec listen(t()) :: {:ok, t(), [listen_option()]} | {:error, any()}
Listen using a transport
Make a new Grizzly.Transport
If need to optionally assign some priv data you can map that into this function.
@spec node_id(t()) :: {:ok, Grizzly.node_id()} | {:error, any()}
Open the transport
Parse the response for the transport
@spec peername(t()) :: {:ok, {:inet.ip_address(), :inet.port_number()}} | {:error, any()}
Send binary data using a transport