Skip to content

GeniusesOfSymfony/WebsocketJsClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!");
});

About

🗿 Javascript Websocket (WAMP) client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published