joewalnes / reconnecting-websocket

A small decorator for the JavaScript WebSocket API that automatically reconnects
MIT License
4.21k stars 968 forks source link

Nodejs #71

Open theavijitsarkar opened 8 years ago

theavijitsarkar commented 8 years ago

Is this a nodejs library? How to use it in nodejs? npm install ?

rohozhnikoff commented 8 years ago

https://www.npmjs.com/package/reconnectingwebsocket

igracia commented 7 years ago

Issue #73 is pointing out that it assumes browser environment. Could this represent a problem when using the library in a server-side app?

intensite commented 7 years ago

How should the library be used as a node module? I tried the following without success:

Installer from npm npm install --save reconnectingwebsocket

var ReconnectingWebSocket = require('reconnectingwebsocket');
ws = new ReconnectingWebSocket("ws://192.168.60.80/PSIA/Metadata/stream?AreaControlEvents=true");

The returned error message:

C:\projets\ws\app2.js:9
 ws = new ReconnectingWebSocket("ws://192.168.60.80/PSIA/Metadata/stream?AreaControlEvents=true");
       ^

TypeError: ReconnectingWebSocket is not a function
    at Object.<anonymous> (C:\projets\ws\app2.js:9:8)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)
    at node.js:963:3
[nodemon] app crashed - waiting for file changes before starting...
nathanboktae commented 7 years ago

This package is for the browser's implementation of WebSocket. Use the ws package for a node.js client WebSocket implementation.