Current section
Files
Jump to
Current section
Files
lib/pixie/messages/disconnect.ex
defmodule Pixie.Message.Disconnect do
defstruct channel: nil, client_id: nil, ext: nil, id: nil
import Pixie.Utils.Message
@moduledoc """
Convert an incoming disconnect message into a struct.
Request
MUST contain * clientId
MAY contain * ext
* id
This struct contains the following keys:
- `:channel` always `"/meta/disconnect"`.
- `:client_id` the client ID generated by the server 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.Disconnect` by copying
only those fields we care about.
"""
def init %{}=message do
%Pixie.Message.Disconnect{}
|> get(message, :channel)
|> get(message, :client_id)
|> get(message, :ext)
|> get(message, :id)
end
end