Elixium Core v0.2.9 Elixium.P2P.GhostProtocol.Message View Source

Create and read messages that are sent over TCP

Link to this section Summary

Functions

Create an unencrypted message that will be passed to a peer, with the contents of message_map

Same as build/2 except the message is encrypted

Read a full unencrypted message from the socket

Validate & decrypt a packet. A packet can contain more than one message

A wrapper function for :gen_tcp.send. Should probably update the typespec to be more accurate with the return value if theres an error

Link to this section Functions

Link to this function build(type, message_map) View Source
build(String.t(), map()) :: String.t()

Create an unencrypted message that will be passed to a peer, with the contents of message_map

Link to this function build(type, message_map, session_key) View Source
build(String.t(), map(), <<_::256>>) :: String.t()

Same as build/2 except the message is encrypted

Link to this function read(socket) View Source
read(reference()) :: map() | {:error, :invalid_protocol}

Read a full unencrypted message from the socket

Link to this function read(data, session_key, socket, messages \\ []) View Source
read(binary(), <<_::256>>, reference(), list()) :: List

Validate & decrypt a packet. A packet can contain more than one message

Link to this function send(message, socket) View Source
send(binary(), reference()) :: :ok | any()

A wrapper function for :gen_tcp.send. Should probably update the typespec to be more accurate with the return value if theres an error.