• Stars
    star
    379
  • Rank 113,004 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Isomorphic implementation of WebSocket (https://www.npmjs.com/package/ws)

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://websocket-echo.com/');

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

More Repositories

1

react-native-animated-linear-gradient

Animated linear gradient as background animation or something else.
JavaScript
219
star
2

rippledb

Embeddable key-value database engine in pure TypeScript, based on LSM-Tree
TypeScript
40
star
3

seashell

🐚 Distributed message queue based on Splashdb (https://github.com/heineiuo/splashdb).
JavaScript
20
star
4

awesome-nodejs-pure-js

Many low level node.js libs written in c/c++ or dependent on native modules. That's awesome, but in some trade off case we need pure javascript lib.
19
star
5

react-native-virtualized-grid

WIP <VirtualizedGrid> component for react-native and react-native-web
TypeScript
12
star
6

react-web

A rich collection of react vendors and components for silky web dev experience.
JavaScript
10
star
7

react-draggable-svg

A react component add drag events(onDragStart, onDrag...) for SVG elements(g, rect, circle...)
JavaScript
9
star
8

expo-adapter-workers

TypeScript
9
star
9

react-native-table

<Table> component for both react-native and react-native-web.
TypeScript
7
star
10

react-native-menu-view

WIP: A <MenuView> for react-native-web
TypeScript
6
star
11

react-native-scrollable-page-view

A React Native PageView for Android, iOS and Web.
TypeScript
5
star
12

pansy

👾 Pansy is a webapp framework in middleware style.
JavaScript
5
star
13

hlsdl

Download HTTP Live Streaming video as a single file from a url with m3u8 content.
JavaScript
4
star
14

react-navigation-switch

`createSwitchNavigator` for react-navigation >= 5
TypeScript
4
star
15

react-native-platform-color

PlatformColor for react-native-web
TypeScript
3
star
16

ding

🔥 Create node.js app
JavaScript
3
star
17

create-changelogs

An action can create changelogs between tags (valid semver messages)
JavaScript
3
star
18

react-native-draftjs

[WIP] Rich editor for react-native based on Draftjs and webview.
JavaScript
2
star
19

react-native-web-switch

TypeScript
2
star
20

react-native-crop-view

2
star
21

demo-pansy-app

An example app built with pansy,jquery,lodash.template,sass,webpack,gulp etc.
JavaScript
2
star
22

shared-js

A collection of utils for javascript.
JavaScript
2
star
23

react-native-tree

A <Tree> based on FlatList
TypeScript
2
star
24

webgl2d

Create CanvasRenderingContext2D from WebGLRenderingContext
TypeScript
1
star
25

demo-node-vm-server

Create server with node.js vm module
JavaScript
1
star
26

gulp-json-omit

compress JSON files omit some keys.
JavaScript
1
star
27

rollup-system-node

JavaScript
1
star
28

react-dropdown

JavaScript
1
star
29

lois

👧 📖 Functional, predictable web framework for node.js
JavaScript
1
star
30

text-parser-url

🔗 text parser for url
JavaScript
1
star
31

react-any-context

JavaScript
1
star
32

deno-react-native-web

1
star
33

react-feather-umd

JavaScript
1
star
34

taskloop

TypeScript
1
star
35

react-native-table-list

TypeScript
1
star
36

system-amd

TypeScript
1
star
37

singleton-virtualized-grid

1
star
38

umd-ui-box

JavaScript
1
star
39

mongo-client-daemon

TypeScript
1
star
40

awesome-react-native-no-native-modules

不需要添加java/ios代码的第三方lib, is truly awesome。
1
star
41

react-icons

fork from https://github.com/gorangajic/react-icons and has been built
JavaScript
1
star
42

react-native-html

JavaScript
1
star
43

github-pkg-npm

TypeScript
1
star
44

date-fns-format-zone

Extend date-fns/format to support format with timezone.
JavaScript
1
star
45

tinyproxy

A tiny reverse proxy server. Support ws->ws, http->http, http->ws modes with auto ssl feature.
JavaScript
1
star
46

use-promise-state

A React hook for Promise
JavaScript
1
star
47

poc-worker-stream

1
star
48

unhandled-rejection-abort

JavaScript
1
star
49

react-as-backend-framework

Use React as a backend framework
TypeScript
1
star
50

get-commit-semver

An action can get semver infomation from latest commit's message.
JavaScript
1
star
51

rippledb-cli

TypeScript
1
star
52

ts-template

TypeScript
1
star
53

url-cached

Load and cache content from any url address.
JavaScript
1
star
54

node-code-screenshot

Take a screenshot photo for code by node.js, written in pure javascript, no native dependencies
JavaScript
1
star
55

use-viewport

JavaScript
1
star
56

read-pdf-as-png

read pdf as png
JavaScript
1
star
57

heineiuo

1
star
58

blog

1
star