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

backend_options()

Returns either the configured backend options, or [name: :ETS].

bayeux_version()

Returns the Bayeux version which Pixie implements. Currently "1.0"

configured_extensions()

Returns a list of the configured extensions.

configured_monitors()

Returns a list of configured event monitors for use by Pixie.Monitor.

enabled_transports()

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(message)

Publish an arbitrary map. This converts the map to a Pixie.Message.Publish struct.

publish(channel, data)

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.

start()
start(, )

Used to start the Pixie application by Mix.

subscribe(channel_name, callback)

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.
subscribe_immediately?()

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.

timeout()

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.

unsubscribe(pid)

Cancel a local subscription.

Example:

Pixie.subscribe "/only_one_please", fn(message,sub)->
  IO.inspect message
  Pixie.unsubscribe sub
end
version()

Returns the currently running Pixie version.