isomorphic-ws

WebJar for isomorphic-ws

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

isomorphic-ws
Last Version

Last Version

4.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

isomorphic-ws
WebJar for isomorphic-ws
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/heineiuo/isomorphic-ws

Download isomorphic-ws

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/isomorphic-ws/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>isomorphic-ws</artifactId>
    <version>4.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/isomorphic-ws/
implementation 'org.webjars.npm:isomorphic-ws:4.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/isomorphic-ws/
implementation ("org.webjars.npm:isomorphic-ws:4.0.1")
'org.webjars.npm:isomorphic-ws:jar:4.0.1'
<dependency org="org.webjars.npm" name="isomorphic-ws" rev="4.0.1">
  <artifact name="isomorphic-ws" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='isomorphic-ws', version='4.0.1')
)
libraryDependencies += "org.webjars.npm" % "isomorphic-ws" % "4.0.1"
[org.webjars.npm/isomorphic-ws "4.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

isomorphic-ws

Isomorphic implementation of WebSocket.

It uses:

Limitations

Before using this module you should know that ws is not perfectly API compatible with WebSocket, you should always test your code against both Node and browsers.

Some major differences:

  • no Server implementation in browsers
  • no support for the constructor options argument in browsers

Usage

You need to install both this package and ws:

> npm i isomorphic-ws ws

Then just require this package:

const WebSocket = require('isomorphic-ws');

const ws = new WebSocket('wss://echo.websocket.org/');

ws.onopen = function open() {
  console.log('connected');
  ws.send(Date.now());
};

ws.onclose = function close() {
  console.log('disconnected');
};

ws.onmessage = function incoming(data) {
  console.log(`Roundtrip time: ${Date.now() - data.data} ms`);

  setTimeout(function timeout() {
    ws.send(Date.now());
  }, 500);
};

License

MIT

Versions

Version
4.0.1