View Source Grizzly.Transport behaviour (grizzly v8.6.6)

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.

t()

Functions

Accept a new connection

Get the assign value for the field

Preform the handshake

Listen using a transport

Open the transport

Parse the response for the transport

Update the assigns with this field and value

Send binary data using a transport

Types

args()

@type args() :: [
  ip_address: :inet.ip_address(),
  port: :inet.port_number(),
  node_id: Grizzly.node_id(),
  transport: t()
]

listen_option()

@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.

parse_opt()

@type parse_opt() :: {:raw, boolean()}

socket()

@type socket() :: :ssl.sslsocket() | :inet.socket()

t()

@opaque t()

Callbacks

accept(t)

@callback accept(t()) :: {:ok, t()} | {:error, any()}

close(t)

@callback close(t()) :: :ok

handshake(t)

@callback handshake(t()) :: {:ok, t()} | {:error, any()}

listen(t)

@callback listen(t()) :: {:ok, t(), [listen_option()]} | {:error, any()}

open(keyword)

@callback open(keyword()) :: {:ok, t()} | {:error, :timeout}

parse_response(any, list)

@callback parse_response(any(), [parse_opt()]) ::
  {:ok, Grizzly.Transport.Response.t() | binary() | :connection_closed}
  | {:error, Grizzly.ZWave.DecodeError.t()}

peername(t)

@callback peername(t()) ::
  {:ok, {:inet.ip_address(), :inet.port_number()}} | {:error, any()}

send(t, binary, keyword)

@callback send(t(), binary(), keyword()) :: :ok

Functions

accept(transport)

@spec accept(t()) :: {:ok, t()} | {:error, any()}

Accept a new connection

get(transport, assign, default \\ nil)

@spec get(t(), atom(), any()) :: any()

Get the assign value for the field

handshake(transport)

@spec handshake(t()) :: {:ok, t()} | {:error, any()}

Preform the handshake

listen(transport)

@spec listen(t()) :: {:ok, t(), [listen_option()]} | {:error, any()}

Listen using a transport

new(impl, assigns \\ %{})

@spec new(module(), map()) :: t()

Make a new Grizzly.Transport

If need to optionally assign some priv data you can map that into this function.

node_id(transport)

@spec node_id(t()) :: {:ok, Grizzly.node_id()} | {:error, any()}

open(transport_module, args)

@spec open(module(), args()) :: {:ok, t()} | {:error, :timeout}

Open the transport

parse_response(transport, response, opts \\ [])

Parse the response for the transport

peername(transport)

@spec peername(t()) ::
  {:ok, {:inet.ip_address(), :inet.port_number()}} | {:error, any()}

put(transport, assign, assign_value)

@spec put(t(), atom(), any()) :: t()

Update the assigns with this field and value

send(transport, binary, opts \\ [])

@spec send(t(), binary(), keyword()) :: :ok

Send binary data using a transport