Current section

Files

Jump to
pixie lib pixie messages connect.ex
Raw

lib/pixie/messages/connect.ex

defmodule Pixie.Message.Connect do
defstruct channel: nil, client_id: nil, connection_type: nil, ext: nil, id: nil
import Pixie.Utils.Message
@moduledoc """
Convert an incoming connect message into a struct.
Request
MUST include: * channel
* clientId
* connectionType
MAY include: * ext
* id
This struct contains the following keys:
- `:channel` always `"/meta/connect"`.
- `:client_id` the client ID generated by the server during handshake.
- `:connection_type` the connection type (transport) the client would like
to use, based on the server's presented options during handshake.
- `:ext` an arbitrary map of data the client sent for use in extensions
(usually authentication information, etc). Optional.
- `:id` a message ID generated by the client. Optional.
"""
@doc """
Convert the incoming message into a `Pixie.Message.Connect` by copying
only those fields we care about.
"""
def init %{}=message do
%Pixie.Message.Connect{}
|> get(message, :channel)
|> get(message, :client_id)
|> get(message, :connection_type)
|> get(message, :ext)
|> get(message, :id)
end
end