Git Product home page Git Product logo

websocket-multiplex's People

Contributors

davidbz avatar kousu avatar majek avatar morrismatts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

websocket-multiplex's Issues

Example for raw websockets

Here's an example for raw websockets (instead of sockjs). It appears that onmessage, onclose, etc, used in the sockjs examples don't apply to raw websockets.

var ws = new WebSocket('ws://' + foo);
var pubsub = new WebSocketMultiplex(ws); 

var logs = pubsub.channel('/logs');
logs.addEventListener('message', function(dataObject) {
  console.log('logs got data ' + dataObject.data);
});

License?

Hello,

Would you mind adding a license to this project?

Thanks much!

Close socket inside channel

The following example code does not work correctly, the end method is undefined.

var ann = multiplexer.registerChannel('ann');
ann.on('connection', function(conn) {
    conn.write('Ann says hi!');
    conn.on('data', function(data) {
        conn.write('Ann nods: ' + data);
        conn.end();
    });
});

If I log the "conn" variable with console.log it outputs:

{ conn:
{ _session:
{ ....

So I'll have to call conn.conn.end to get this to work.

node v0.10.33

Can't create multiple client-side connections to the same server-channel

I was trying to fixup some code that uses multiple SockJS instances to use WebSocketMultiplex instead.

But it seems that there is an built-in assumption that I can not open more than one simultaneous channel with the same name.

I.e.

   var newsChannelForBob = multiplexer.channel('news');
   var newsChannelForAnn = multiplexer.channel('news');

The second call overwrites the first call's instance in 'channels' registry. This leads to problems down the line.

I think that when I write similar code using 'SockJS' directly this works fine and I simply get two independent socket instances each openening a independent websockets connection to the server, connecting to the same websocket url.

If I am correct (not really 100% sure, as not an expert on websockets) then WebSocketMultiplex isn't really what it purports to be. I.e. a transparant replacement for directly using SockJS.

Is this a problem with WebSocketMultiplex? Or is it rather a bug in my understanding / use of the websocket API?

Is there a way to open multiple independent client side channels to the same server-side 'service'?

I would rather avoid implementing my own multiplexer if possible :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.