Current section

Files

Jump to
pixie lib pixie responses unsubscribe.ex
Raw

lib/pixie/responses/unsubscribe.ex

defmodule Pixie.Response.Unsubscribe do
defstruct channel: "/meta/unsubscribe", client_id: nil, subscription: nil, error: nil, advice: nil, ext: nil, id: nil
import Pixie.Utils.Response
@moduledoc """
Convert an incoming `Pixie.Message.Unsubscribe` into a response.
Response
MUST include: * channel
* successful
* clientId
* subscription
MAY include: * error
* advice
* ext
* id
This struct contains the following keys:
- `:channel` always `"/meta/unsubscribe"`.
- `:client_id` the client ID generated by the server during handshake.
- `:error` an error message to send to the client explaining why the
request cannot proceed. Optional.
- `:ext` an arbitrary map of data the server sends for use in extensions
(usually authentication information, etc). Optional.
- `:id` a message ID generated by the client. Optional.
- `:advice` advice from the server about how to handle timeouts, polling
intervals, etc. See
[the Bayeux protocol](http://svn.cometd.org/trunk/bayeux/bayeux.html#toc_32)
for more information.
"""
@doc """
Create a `Pixie.Response.Unsubscribe` struct based on some fields from the
incoming message.
"""
def init %Pixie.Message.Unsubscribe{}=message do
%Pixie.Response.Unsubscribe{}
|> put(message, :id)
|> put(message, :client_id)
|> put(message, :subscription)
end
end