Pico v0.1.2 Pico View Source

Main functions for proper usage of Pico

Link to this section Summary

Functions

Send a message to all connected peers

Attempt a connection to the given IP address on the given port. This will go through all authentication steps.

Returns a list of all handlers that have an active Pico connection open with a peer

Encode and encrypt a message with no data section according to the Pico specification

Encode and encrypt a message with a data section according to the Pico specification

Returns a list of all handlers started by start/4

Tell a given handler to listen for and route messages

Tell all Pico handlers created by start/4 to listen for and route messages

Send a message containing only an OpName to a connection.

Send a message to a connection.

Start a Pico app to facilitate Pico connections. Necessary if you aren't handling Pico messages yourself and instead want a http-like message routing system to listen and respond to messages.

Link to this section Types

Link to this type

connection() View Source
connection() :: {pid(), binary(), binary()}

Link to this type

handler() View Source
handler() :: {atom(), pid()}

Link to this section Functions

Link to this function

broadcast(opname, data \\ nil) View Source
broadcast(String.t(), map() | nil) :: none()

Send a message to all connected peers

Link to this function

connect(ip, port \\ 31013) View Source
connect(bitstring(), integer()) :: {:ok, connection()} | {:error, String.t()}

Attempt a connection to the given IP address on the given port. This will go through all authentication steps.

Link to this function

connected_handlers() View Source
connected_handlers() :: [handler()]

Returns a list of all handlers that have an active Pico connection open with a peer

Link to this function

encode(opname, key, iv) View Source
encode(String.t(), binary(), binary()) :: binary() | {:error, String.t()}

Encode and encrypt a message with no data section according to the Pico specification

Link to this function

encode(opname, data, key, iv) View Source
encode(String.t(), map(), binary(), binary()) ::
  binary() | {:error, String.t()}

Encode and encrypt a message with a data section according to the Pico specification

Link to this function

handlers() View Source
handlers() :: [handler()]

Returns a list of all handlers started by start/4

Link to this function

listen(handler_pid) View Source
listen(pid()) :: none()

Tell a given handler to listen for and route messages

Link to this function

listen_all_handlers() View Source
listen_all_handlers() :: none()

Tell all Pico handlers created by start/4 to listen for and route messages

Link to this function

message(socket, opname) View Source
message(connection(), String.t()) :: :ok | {:error, String.t()}

Send a message containing only an OpName to a connection.

Link to this function

message(socket, opname, data) View Source
message(connection(), String.t(), map()) :: :ok | {:error, String.t()}

Send a message to a connection.

Link to this function

start(router, peers \\ [], port \\ 31013, handlers \\ 10) View Source
start(atom(), list(), integer(), integer()) ::
  {:ok, pid()} | {:error, String.t()}

Start a Pico app to facilitate Pico connections. Necessary if you aren't handling Pico messages yourself and instead want a http-like message routing system to listen and respond to messages.

By default, handlers do not listen for messages, and must be told to listen by calling either listen/1 or listen_all_handlers/0