1. DreamFactory
  2. Untitled project
  3. lib-faye

Wiki

Clone wiki

lib-faye / Home

lib-pubsub

This library is a very thin wrapper around Faye, an excellent pub/sub application for node.js.

The DreamFactory hosting infrastructure contains a Faye server running on port 9292 and is available to all DSPs.

Concepts

Channels

Metachannel

Usage

Channels

Construction

Publishing

Subscribing

Disabling

Example Code

Base Sample Client

This is a dead simple client. It doesn't nothing but subscribe to the /updates channel and logs any data received.

<?php
?>
<html>
<head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head>
<body>
Faye tester
<script src="//api.cloud.dreamfactory.com:9292/bayeux/client.js"></script>
<script src="/js/PubSub.js"></script>
<script type="text/javascript">
    jQuery(function ($) {
        var _relay = new PubSub.Client('http://api.cloud.dreamfactory.com:9292/bayeux');

        _relay.subscribe('/updates', function (data) {
            console.log('Received data from /updates: ' + JSON.stringify(data));
        });
    });
</script>
</body>
</html>

The DreamFactory servers send out a timestamp on this channel once per minute. So you should see things popping up in your console after a few minutes.

TODO

  1. Make RequireJS compatible package.
  2. Investigate npm distribution.

Updated