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
connection() View Source
handler() View Source
Link to this section Functions
broadcast(opname, data \\ nil) View Source
Send a message to all connected peers
connect(ip, port \\ 31013)
View Source
connect(bitstring(), integer()) :: {:ok, connection()} | {:error, String.t()}
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.
connected_handlers()
View Source
connected_handlers() :: [handler()]
connected_handlers() :: [handler()]
Returns a list of all handlers that have an active Pico connection open with a peer
encode(opname, key, iv) View Source
Encode and encrypt a message with no data section according to the Pico specification
encode(opname, data, key, iv) View Source
Encode and encrypt a message with a data section according to the Pico specification
handlers()
View Source
handlers() :: [handler()]
handlers() :: [handler()]
Returns a list of all handlers started by start/4
listen(handler_pid) View Source
Tell a given handler to listen for and route messages
listen_all_handlers()
View Source
listen_all_handlers() :: none()
listen_all_handlers() :: none()
Tell all Pico handlers created by start/4 to listen for and route messages
message(socket, opname)
View Source
message(connection(), String.t()) :: :ok | {:error, String.t()}
message(connection(), String.t()) :: :ok | {:error, String.t()}
Send a message containing only an OpName to a connection.
message(socket, opname, data)
View Source
message(connection(), String.t(), map()) :: :ok | {:error, String.t()}
message(connection(), String.t(), map()) :: :ok | {:error, String.t()}
Send a message to a connection.
start() View Source
start(router, peers \\ [], port \\ 31013, handlers \\ 10) View Source
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