larasopp
v1.2.21
Published
Websocket client for laravel
Downloads
45
Maintainers
Readme
Laravel websocket client
Server
https://www.npmjs.com/package/larasopp-server
Laravel package
composer require larasopp/larasopp
Connect app to websocket
...
import Larasopp from "Larasopp";
const larasopp = new Larasopp({
host: 'ws://127.0.0.1:3001',
token: 'token'
});
larasopp.connect();
//or
larasopp.connect('token');
Update user token
larasopp.setToken('new token');
Subscribe on channel and listen event
const listener = larasopp.subscribe('chat').listen('message',(data) => {
console.log(data.text); // Hello World
});
// Unsubscribe event
listener.remove();
Trigger event on subscribe channel
larasopp.trigger('chat','message',{
text: 'Hello World'
},'public');
Unsubscribe channel
larasopp.unsubscribe('chat');
Disconnect
larasopp.disconnect();
Permissions
'public' | 'protected' | 'private'