🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

w-websocket-client

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

w-websocket-client

A wrapper for websocket in nodejs and browser.

1.0.29
latest
Source
npm
Version published
Weekly downloads
522
201.73%
Maintainers
1
Weekly downloads
 
Created
Source

w-websocket-client

A wrapper for websocket in nodejs and browser.

language npm version license gzip file size npm download npm download jsdelivr download

Documentation

To view documentation or get support, visit docs.

Installation

Using npm(ES6 module):

Note: w-websocket-client is mainly dependent on ws

npm i w-websocket-client

Example for w-websocket-client:

Link: [dev source code]

import WSC from 'w-websocket-client/dist/w-websocket-client.umd.js'

let opt = {
    url: 'ws://localhost:8080',
    token: '*',
    open: function() {
        console.log('client nodejs: open')

        //send
        wsc.send('abc')

    },
    close: function() {
        console.log('client nodejs: close')
    },
    message: function(data) {
        console.log('client nodejs: message', data)
    },
    error: function(err) {
        console.log('client nodejs: error:', err)
    },
}

//WSC
let wsc = new WSC(opt)

In a browser(UMD module):

Note: w-websocket-client does't depend on any package in browser.

[Optional] Add script with nomodule for IE11.

<script nomodule src="https://cdn.jsdelivr.net/npm/@babel/polyfill/dist/polyfill.min.js"></script>

[Necessary] Add script for w-websocket-client.

<script src="https://cdn.jsdelivr.net/npm/w-websocket-client@1.0.29/dist/w-websocket-client.umd.js"></script>

Example for w-websocket-client:

Link: [dev source code]

//opt
let opt = {
    url: 'ws://localhost:8080',
    token: '*',
    open: function() {
        console.log('client web: open')

        //send
        wsc.send('abc')

    },
    close: function() {
        console.log('client web: close')
    },
    message: function(data) {
        console.log('client web: message', data)
    },
    error: function(err) {
        console.log('client web: error:', err)
    },
}

//WSC
let WSC = window['w-websocket-client']
let wsc = new WSC(opt)

Keywords

package

FAQs

Package last updated on 24 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts