To receive Womack events in the client, pull Womack’s script into the page, and instantiate a Womack:
<html>
<head>
<script src="http://localhost:8111/womack.js"></script>
</head>
<body>
<!-- ... your page here -->
<script>
var womack = new Womack();
womack.on('connect', function () { /* ... */ });
womack.on('disconnect', function () { /* ... */ });
womack.subscribe('the channel', function (message) { /* ... */ });
</script>
</body>
</html>
If you need direct access to socket.io functions, you can access them via the womack instance’s io property.
Womack client, used to receive messages from a Womack server.
Arguments: |
|
---|
Register a callback for a socket event. Most common events to watch for are "connect" and "disconnect" – but you can register a callback for any socket.io event.
Subscribe to a Womack channel. This is the primary client interface (at least for the stock Womack server). This will register your socket as a receiver of messages on the given channel, and your callback will be called with the message (already decoded from JSON) whenever a message is published to that channel by a womack.publish.Publisher that is connected to the same redis server that the socket server is connected to.
The socket.io object that Womack uses to communicate with the socket server.