1.1.8 • Published 4 years ago
@dalisoft/ws-events-sync v1.1.8
ws-events-sync
Event sync between server and client in Websocket
Features
- Node.js wrapper
- Browser wrapper
- Fast
- Performant
- Easy
- UMD compatible
Installation
We recommend install via npm
because of it's cache and flat node modules tree
npm i @dalisoft/ws-events-sync
then you able to import to Node.js/Browser easily
// Node.js
const WSEventsWrapper = require("@dalisoft/ws-events-sync").Server;
// Browser
// window.WSEventsSync.Client OR WSEventsSync.Client
// ES6
import { Client /* Server */ } from "@dalisoft/ws-events-sync";
Usage
// Client
const ws = new Websocket("ws://{WEBSOCKET_URL}");
const wsc = new Client(ws);
wsc.emit("server-event", {
type: "ping"
});
wsc.on("client-event", data => console.log("client event emitter", data));
// Server
const ws = new WSServer();
ws.on("connection", client => {
const wss = new Server(client);
wss.emit("client-event", {
type: "pong"
});
wss.on("server-event", data => console.log("server event emitter", data));
});
Browser snippet
Add this script into your before script and after body to be this library working out-of-the-box.
Thanks to jsDelivr!
<script src="https://cdn.jsdelivr.net/combine/npm/@dalisoft/args,npm/@dalisoft/events,npm/@dalisoft/ws-events-sync"></script>
License
MIT
1.1.8
4 years ago
1.1.7
4 years ago
1.1.6
4 years ago
1.1.5
4 years ago
1.1.4
4 years ago
1.1.3
4 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.0
5 years ago
0.0.12
5 years ago
0.0.11
5 years ago
0.0.10
5 years ago
0.0.9
5 years ago
0.0.8
5 years ago
0.0.7
5 years ago
0.0.6
5 years ago
0.0.5
5 years ago
0.0.4
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago