pixie v0.3.9 Pixie
This module defines sensible defaults for all user configurable options, and
provides a few helper functions, such as publish
and subscribe
.
Summary
Functions
Returns either the configured backend options, or [name: :ETS]
Returns the Bayeux version which Pixie implements. Currently "1.0"
Returns a list of the configured extensions
Returns a list of configured event monitors for use by Pixie.Monitor
Returns a list of the currently enabled transports. This can be configured with
Publish an arbitrary map. This converts the map to a Pixie.Message.Publish
struct
Publish a message to the specified channel. This saves you from having to
build the Pixie.Message.Publish
yourself, you can simply specify the
channel to publish to and an arbitrary map for the message’s data
property
Used to start the Pixie application by Mix
Subscribe to a channel and call the provided function with messages
The Bayeux protocol is undecided as to whether subscription requests should be responded to immediately, or can wait until either the next connect timeout, or the next message arrives for delivery to the client
Returns configured timeout in milliseconds.
Defaults to 25000
if nothing is configured
Cancel a local subscription
Returns the currently running Pixie version
Functions
Returns a list of configured event monitors for use by Pixie.Monitor
.
Returns a list of the currently enabled transports. This can be configured with:
config :pixie, :enabled_transports, ~w| long-polling websocket |
Defaults to ["long-polling", "cross-origin-long-polling", "callback-polling", "websocket"]
.
Publish an arbitrary map. This converts the map to a Pixie.Message.Publish
struct.
Publish a message to the specified channel. This saves you from having to
build the Pixie.Message.Publish
yourself, you can simply specify the
channel to publish to and an arbitrary map for the message’s data
property.
Subscribe to a channel and call the provided function with messages.
{:ok, sub} = Pixie.subscribe "/my_awesome_channel", fn(message,_)->
IO.inspect message
end
The function must take two arguments:
- A message struct.
- The subscription pid.
The Bayeux protocol is undecided as to whether subscription requests should be responded to immediately, or can wait until either the next connect timeout, or the next message arrives for delivery to the client.
By default Pixie waits to send subscribe requests, however if you have client’s expecting an immediate response to subscriptions you can turn this on.
An example of why you may want to send subscription responses immediately:
client = new Faye.Client("http://my.chat.server/pixie");
client.subscribe("/foyer").then(function() {
client.publish("/foyer", {message: "New user joined channel #foyer"})
}, function(err) {
alert("Unable to join #foyer: " + err)
});
See Faye’s documentation for more information.
Returns configured timeout in milliseconds.
Defaults to 25000
if nothing is configured.
This value is used by Pixie to decide how long to wait between connect responses, and various multiples are used for client expiry timeouts, etc.
Cancel a local subscription.
Example:
Pixie.subscribe "/only_one_please", fn(message,sub)->
IO.inspect message
Pixie.unsubscribe sub
end