-
-
Notifications
You must be signed in to change notification settings - Fork 307
streamable browser variant for browserify #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
With this API people will be able to use the new pipe-able dnode api like this: var domready = require('domready');
var sockjs = require('sockjs');
var dnode = require('dnode');
domready(function () {
var result = document.getElementById('result');
var stream = sockjs('/dnode');
var d = dnode();
d.on('remote', function (remote) {
remote.transform('beep', function (s) {
result.textContent = 'beep => ' + s;
});
});
d.pipe(stream).pipe(d);
}); |
+1 |
This should be a layer on top of the WebSocket API. That way you can use it with raw WebSockets or with SockJS. If you added to SockJS, it will only work with SockJS, which is exactly not what SockJS is trying to accomplish. |
@ignorw Very true, and that's something that should be taken into consideration. However, I think this patch is justified because:
If this patch is rejected and assuming the sockjs-client patch goes through I will gladly create a sockjs-stream module, but in this case I think being able to use the same |
Full disclosure, this issue is sort of related to #67. ;-) |
I'm very confused. Is this patch adding a code to a server-side node.js project, that when run from the browser will use sockjs-client? Why? |
Hmm... I'm quite sure doing any sockjs-client things should not be a part of sockjs-node server. @substack Do you think the same functionality can be achieved by launching a separate project (you suggested sockjs-stream)? I think I'm happy to merge sockjs/sockjs-client#76 BTW. |
Or is it:
That sounds wrong. Why not make this thing part of sockjs-client or something on top of sockjs-client? Am I right that sockjs-node is completely unrelated to what we want to achieve? |
browserify's primary goal is to let users use modules from npm in the browser so that programmers can use the same apis in the server and the client. Since sockjs-node already offers a stream in node and browserify has compatability layers for making streams work, this patch was intended to increase the correspondence when using browserify. The patches to sockjs-client are separate and merely let you |
At any rate, I just made this project instead: http://github.com/substack/shoe |
This pull request depends on sockjs/sockjs-client#76 in sockjs-client to work.
This patch adds a streamable wrapper around sockjs-client so that people can do
require('sockjs')
in browserify or a similar node-style require() bundler and use .pipe() and friends on the browser-side like the present node-side api.