Sippet v1.0.1 Sippet View Source

Holds the Sippet stack.

Network transport protocols should be registered during initialization:

def init(_) do
  Sippet.register_transport(:udp, false)
  ...
end

Messages are dispatched to transports by sending the following message:

send(pid, {:send_message, message, host, port, transaction})

Whenever a message is received by a transport, the function Sippet.handle_transport_message is called, which will validate and route messages through the transaction layer or send directly to the core.

Link to this section Summary

Types

A client transaction identifier

An network error that occurred while sending a message

A SIP message request

A SIP message response

A server transaction identifier

Sippet identifier

Functions

Returns a specification to start this module under a supervisor.

Registers the stack core.

Registers a transport for a given protocol.

Verifies if the transport protocol used to send the given message is reliable.

Sends a message (request or response) using transactions if possible.

Handles the sigil ~K.

Terminates a client or server transaction forcefully.

Link to this section Types

A client transaction identifier

An network error that occurred while sending a message

A SIP message request

A SIP message response

A server transaction identifier

Sippet identifier

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

register_core(sippet, module)

View Source
register_core(sippet(), atom()) :: :ok

Registers the stack core.

Link to this function

register_transport(sippet, protocol, reliable)

View Source
register_transport(sippet(), atom(), boolean()) ::
  :ok | {:error, :already_registered}

Registers a transport for a given protocol.

Link to this function

reliable?(sippet, message)

View Source
reliable?(sippet(), Sippet.Message.t()) :: boolean()

Verifies if the transport protocol used to send the given message is reliable.

Link to this function

send(sippet, message)

View Source
send(sippet(), request() | response()) :: :ok | {:error, reason()}

Sends a message (request or response) using transactions if possible.

Requests of method :ack is sent directly to the transport layer.

A Sippet.Transactions.Client is created for requests to handle client retransmissions, when the transport presumes it, and match response retransmissions, so the Sippet.Core doesn't get retransmissions other than 200 OK for :invite requests.

In case of success, returns :ok.

Handles the sigil ~K.

It returns a client or server transaction key depending on the number of parameters passed.

Examples

iex> import Sippet, only: [sigil_K: 2]

iex> Sippet.Transactions.Client.Key.new("z9hG4bK230f2.1", :invite)
~K[z9hG4bK230f2.1|:invite]

iex> ~K[z9hG4bK230f2.1|INVITE]
~K[z9hG4bK230f2.1|:invite]

iex> Sippet.Transactions.Server.Key.new("z9hG4bK74b21", :invite, {"client.biloxi.example.com", 5060})
~K[z9hG4bK74b21|:invite|client.biloxi.example.com:5060]

iex> ~K[z9hG4bK74b21|INVITE|client.biloxi.example.com:5060]
~K[z9hG4bK74b21|:invite|client.biloxi.example.com:5060]
Link to this function

terminate(sippet, key)

View Source
terminate(sippet(), client_key() | server_key()) :: :ok

Terminates a client or server transaction forcefully.

This function is not generally executed by entities; there is a single case where it is fundamental, which is when a client transaction is in proceeding state for a long time, and the transaction has to be finished forcibly, or it will never finish by itself.

If a transaction with such a key does not exist, it will be silently ignored.