sockjs / websocket-multiplex Goto Github PK
View Code? Open in Web Editor NEWA thin library for doing multiplexing on top of SockJS
Home Page: https://github.com/sockjs/websocket-multiplex
License: MIT License
A thin library for doing multiplexing on top of SockJS
Home Page: https://github.com/sockjs/websocket-multiplex
License: MIT License
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);
});
Hello,
Would you mind adding a license to this project?
Thanks much!
First: great work. Thanks!
When I create a channel after using an existing one, the subscribe is not called.
I just looked into the code and found a way how to solve this issue
If I call onopen
immediately an not on next tick (what is strangely not working) it works like a charm.
https://github.com/sockjs/websocket-multiplex/blob/master/multiplex_client.js#L68
Whats the problem here?
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
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 :-)
I would like to use my modified version of this library in scripted:
https://github.com/scripted-editor/scripted
If it can be made available under the same licence as sockjs itself then that seems possible (we are already using sockjs).
I assume that won't be a problem... but I don't see any copyright infos anywhere in/on this library at the moment.
browser reports
GET http://localhost:9999/multiplex/info 404 (Not Found)
I'm closing this issue. Feel free to file a new bug or reopen if you encounter more problems.
Originally posted by @majek in sockjs/sockjs-node#57 (comment)
Let's modify the basic example to support Express 3.0.
Hi,
Just wanted to let you know the following URI in the README.md https://d1fxtkz8shb9d2.cloudfront.net/websocket-multiplex-0.1.js doesn't work anymore. Changed to https://aws.amazon.com/cloudfront/...
I'm using this now: https://cdn.jsdelivr.net/npm/[email protected]/multiplex_client.min.js
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.