Phoenix.Socket.Serializer behaviour (Phoenix v1.6.0-rc.0) View Source

A behaviour that serializes incoming and outgoing socket messages.

By default Phoenix provides a serializer that encodes to JSON and decodes JSON messages.

Custom serializers may be configured in the socket.

Link to this section Summary

Callbacks

Decodes iodata into Phoenix.Socket.Message struct.

Encodes Phoenix.Socket.Message and Phoenix.Socket.Reply structs to push format.

Encodes a Phoenix.Socket.Broadcast struct to fastlane format.

Link to this section Callbacks

Link to this callback

decode!(iodata, options)

View Source

Specs

decode!(iodata(), options :: Keyword.t()) :: Phoenix.Socket.Message.t()

Decodes iodata into Phoenix.Socket.Message struct.

Specs

encode!(Phoenix.Socket.Message.t() | Phoenix.Socket.Reply.t()) ::
  {:socket_push, :text, iodata()} | {:socket_push, :binary, iodata()}

Encodes Phoenix.Socket.Message and Phoenix.Socket.Reply structs to push format.

Specs

fastlane!(Phoenix.Socket.Broadcast.t()) ::
  {:socket_push, :text, iodata()} | {:socket_push, :binary, iodata()}

Encodes a Phoenix.Socket.Broadcast struct to fastlane format.