View Source Nex.Messages.Msg (Nex v0.1.0-beta.1)

Nostr Message schema.

Use this module to decode and encode message strings passed over the websocket connection.

Internally Nex passes messages around as tuples so we can take advantage of pattern matching.

Link to this section Summary

Types

t()

Message

Functions

Decodes the given message string into a tuple.

Encodes the given message tuple into a string.

Link to this section Types

@type t() ::
  {:EVENT, map()}
  | {:REQ, String.t(), [map()]}
  | {:CLOSE, String.t()}
  | {:EVENT, String.t(), map()}
  | {:NOTICE, String.t()}
  | {:EOSE, String.t()}
  | {:OK, String.t(), boolean(), String.t()}

Message

Link to this section Functions

@spec decode(String.t()) :: {:ok, t()} | {:error, term()}

Decodes the given message string into a tuple.

@spec encode(t()) :: String.t()

Encodes the given message tuple into a string.