gos-socket-client
v0.0.8
Published
Client side implementation for GeniusesOfSymfony/WebSocketBundle.
Downloads
6
Readme
Installation
npm i gos-socket-client
Using - only for browsers
- Include javascript libraries GeniusesOfSymfony/WebSocketBundle
<script src="{{ asset('bundles/goswebsocket/js/vendor/autobahn.min.js') }}"></script>
<script src="{{ asset('bundles/goswebsocket/js/websocket.min.js') }}"></script>
- Check in browser console if GosSocket is available
console.log(GosSocket);
- Use GoSocketclient
import {GosSocketClient} from "gos-socket-client";
const wsOptions = {
url: 'wss://my-web.test/websocket',
pingChannel: 'ping/channel',
};
const ws = GosSocketClient.getInstance(wsOptions);
ws.subscribe('myChat/channel', () => {});
ws.publish('myChat/channel', {
msg: 'Hello world',
});
ws.unsubscribe('myChat/channel');