1.0.16 • Published 7 years ago
saphir-webchaussette-client v1.0.16
Saphir WebChaussette Client
WebSockets abstraction to be used with Saphir php framework, on client side.
Installation
Download and install npm at www.npmjs.com/get-npm if you haven't already.
npm install saphir-webchaussette-clientThis package is provided in ES6 module format.
Usage
import WebChaussetteClient from 'saphir-webchaussette-client';
var chaussette = new WebChaussetteClient();
chaussette.connect('localhost:8080', function(socket)
{
    socket.subscribeTo('notification_room');
    socket.on('notification', function(data)
    {
        // Do something
    });
});If your Saphir installation is not at the root of the domain (for example if you use a lamp), like http://localhost/my-sites/test/public, you can give the root url like this :
import WebChaussetteClient from 'saphir-webchaussette-client';
var chaussette = new WebChaussetteClient();
chaussette.connect('localhost:8080', function(socket)
{
    socket.subscribeTo('notification_room');
    socket.on('notification', function(data)
    {
        // Do something
    });
},
[
	rootUrl: 'http://localhost/my-sites/test/public' // Be careful to give the url without the "/" at the end
]);If you have to give a CSRF Token, you can do :
import WebChaussetteClient from 'saphir-webchaussette-client';
var chaussette = new WebChaussetteClient();
chaussette.connect('localhost:8080', function(socket)
{
    socket.subscribeTo('notification_room');
    socket.on('notification', function(data)
    {
        // Do something
    });
},
[
	csrfTokenInputName: '_token',
	csrfToken: '...' // Your csrf token
]); // Be careful to give the url without the "/" at the end