0.0.3 • Published 8 months ago

fast-websocket v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

fast-websocket

About

A concise websocket tool that can quickly create a server or client, supporting data requests like HTTP requests

How use

npm

npm i fast-websocket --save

yarn

yarn add fast-websocket -S

server example

const WS = require("fast-websocket");

let ws = new WS({ port: 90 });

ws.startServer();
ws.on("got", function (currClient, json) {
  console.log("got", json);
  json.data = new Date().toLocaleTimeString();
  currClient.ws.send(JSON.stringify(json));
});

client example

let ws = new WS({ url: "ws://localhost:90" });

ws.connect();

async function main() {
  let res = await ws.got({
    way: "time",
    action: "now",
  });
  console.log(res);
}
ws.on("open", function () {
  main();
});
0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago