@travic/ws
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

WS

To install;

npm i @travic/ws
// or
yarn add @travic/ws

To use, import or require package;

import { WS } from '@travic/ws';
// or
const { WS } = require('@travic/ws');

// example use

const url = 'ws://examplewebsocket.com';

// second arg is for websocket options.
const ws = WS.newWebsocket(url);

// first arg set to true will console.log the event.
ws.connect(true, event => {// do something with event});

ws.disconnect(true, event => {// do something with event});

// recieves data
ws.message(true, event => {// do something with event});

// Sends data.
 - Passing a string as arg will send that string.
 - Passing an object as arg will send that object as json.

ws.send({// data to send});
ws.send("// data to send");

Readme

Keywords

Package Sidebar

Install

npm i @travic/ws

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

5.21 kB

Total Files

6

Last publish

Collaborators

  • travic