View Source ExTURN.Client (ex_turn v0.2.0)
Memory-based TURN client.
Summary
Types
Internal notification message.
Messages that can be passed to handle_message/2
.
Notifications emitted by the client.
Return values of handle_message/2
.
Type describing ExTURN.Client
struct.
Types
@type addr() :: {:inet.ip_address(), :inet.port_number()}
@opaque internal_notification_message()
Internal notification message.
Has to be passed back to the client with handle_message/2
.
@type message() :: {:socket_data, :inet.ip_address(), :inet.port_number(), binary()} | internal_notification_message()
Messages that can be passed to handle_message/2
.
@type notification() :: {:ex_turn, client_ref :: reference(), msg :: public_notification_message() | internal_notification_message()}
Notifications emitted by the client.
@type on_handle_message() :: {:ok, t()} | {:send, addr(), binary(), t()} | {:allocation_created, addr(), t()} | {:permission_created, :inet.ip_address(), t()} | {:permission_expired, :inet.ip_address(), t()} | {:channel_created, addr(), t()} | {:channel_expired, addr(), t()} | {:data, src :: addr(), binary(), t()} | {:error, reason :: atom(), t()}
Return values of handle_message/2
.
:ok
- no further actions are required.:send
- requires data to be sent over a socket owned by the user.:allocation_created
- an allocation has been successfully created.:permission_created
- a permission has been successfully created and the client is ready to send data withsend/3
.:permission_expired
- a permission could not be refreshed and eventually expired. Together with expired permission, all channels bound to the permission ip also expire.:channel_created
- a channel has been successfully created and all subsequent calls tosend/3
will use channel data message format.:channel_expired
- a channel could not be refreshed and eventually expired.:data
- data has been received from a peer.:error
- an error has occured and the client cannot be used anymore.
@type public_notification_message() :: {:allocation_expired, addr()} | {:permission_expired, :inet.ip_address()} | {:channel_expired, addr()}
@type t() :: %ExTURN.Client{ addr_channel: %{required(addr()) => pos_integer()}, alloc_exp_timer: reference(), channel_addr: %{required(pos_integer()) => addr()}, channel_timer: %{required(pos_integer()) => reference()}, key: binary(), nonce: binary(), password: binary(), permissions: %{ required(:inet.ip_address()) => %{ refresh_timer: reference(), exp_timer: reference() } }, realm: binary(), ref: reference(), state: :new | :auth | :alloc | :allocated | :error, transactions: %{required(transaction_id :: integer()) => ExSTUN.Message.t()}, turn_ip: :inet.ip_address(), turn_port: :inet.port_number(), uri: ExSTUN.URI.t(), username: binary() }
Type describing ExTURN.Client
struct.
Possible states:
:new
- the first allocation request has not been sent yet:auth
- the first allocation request has been sent:alloc
- an actuall allocation request with auth attributes has been sent:allocated
- an allocation has been successfully created:error
- an error has occured and the client cannot be used anymore.
Functions
@spec create_channel(t(), :inet.ip_address(), :inet.port_number()) :: {:ok, t()} | {:send, addr(), binary(), t()}
@spec create_permission(t(), :inet.ip_address()) :: {:send, addr(), binary(), t()}
@spec handle_message(t(), message()) :: on_handle_message()
@spec has_channel?(t(), :inet.ip_address(), :inet.port_number()) :: boolean()
@spec has_permission?(t(), :inet.ip_address()) :: boolean()
@spec new(ExSTUN.URI.t(), binary(), binary()) :: {:ok, t()} | {:error, :unsupported_turn_uri | :invalid_turn_server}