ChannelClient. Message
(channel_client v0.1.0)
Copy Markdown
A struct representing a single Phoenix channel message.
The wire format is determined by the protocol version serializer:
ChannelClient.Message.V1- JSON object encoding (vsn: "1.0.0")ChannelClient.Message.V2- JSON array encoding (vsn: "2.0.0")
Payloads may be any value the configured json_library can encode, which
includes maps, lists, strings, numbers, booleans and nil.
Summary
Functions
Like decode!/3, but returns {:error, reason} instead of raising.
Decodes a raw transport payload into a %Message{}, raising on failure.
Like encode!/3, but returns {:error, reason} instead of raising.
Encodes a %Message{} into its raw transport representation, raising on
failure.
Returns the serializer module for a given Phoenix protocol version.
Types
Functions
Like decode!/3, but returns {:error, reason} instead of raising.
Used at the socket boundary so that malformed frames from the server are logged and dropped instead of crashing the connection.
Decodes a raw transport payload into a %Message{}, raising on failure.
Transport payloads must be valid JSON produced by the matching protocol version.
Like encode!/3, but returns {:error, reason} instead of raising.
Used so that unencodable payloads (for example tuples or references) are reported to the caller rather than killing the socket process.
Encodes a %Message{} into its raw transport representation, raising on
failure.
Returns the serializer module for a given Phoenix protocol version.
Examples
iex> ChannelClient.Message.serializer("2.0.0")
ChannelClient.Message.V2