gos-websocket-mognedy
v0.1.0
Published
GosWebsocket Client Side of GosWebsocketBundle
Downloads
3
Readme
Gos Webscoket (JS Client)
About
It's Javascript client for Gos Websocket Bundle
Development
This project is very simple, just run gulp serve
to generate distribution file.
Install
Bower
bower install gos-websocket-client
Old school
<script type="text/javascript" src="dist/websocket.js"></script>
Usage
Connection
var websocket = WS.connect("ws://127.0.0.1:8080");
On Connect
webSocket.on("socket/connect", function(session){
//session is an Autobahn JS WAMP session.
console.log("Successfully Connected!");
});
On Disconnect
webSocket.on("socket/disconnect", function(error){
//error provides us with some insight into the disconnection: error.reason and error.code
console.log("Disconnected for " + error.reason + " with code " + error.code);
});
Pub/Sub
webSocket.on("socket/connect", function(session){
//the callback function in "subscribe" is called everytime an event is published in that channel.
session.subscribe("acme/channel", function(uri, payload){
console.log("Received message", payload.msg);
});
session.publish("acme/channel", "This is a message!");
});