I've been playing with getUserData, node.js and a very simple
websocket broadcast server - copied from
http://francisshanahan.com/index.php/2011/stream-a-webcam-using-javascript-nodejs-android-opera-mobile-web-sockets-and-html5/

I have both source and client devices connected to websockets on node,
and it kinda works, BUT, there seems to be some kind of buffering
going on, even outside of the node process context. If I run my node
js (included below), then connect both devices, the client device
seems to receive a very historical frame from a previous source
websocket connection, and go on from there. Not the first frame
uploaded over this instance of the connection. If I Ctrl+c my node
instance, and start it again, the historical frames persist. I'm
running a Debian squeeze box if that's of any use context wise.

I have the raw image source echoing onto the client page, so I can see
that the consuming client is actually updating once for each frame
received by the websocket from the source device, but it's just not
the expected frame.

This is my first time playing with node, so I have very little context
to begin nutting this out.

All advice is welcome.

Thanks,
   Simeon.

My server code is below:

var sys = require("util"),
    ws = require("./ws.js");
var clients = [];

ws.createServer(
        function (websocket) {

                clients.push(websocket);

                websocket.addListener("connect", function (resource) {
                        // emitted after handshake
                        sys.debug("connect: " + resource);
                }).addListener("data", function (data) {

                // handle incoming data
                // send data to ALL clients whenever ANY client send
up data
                for (var i = 0 ; i < clients.length ; i ++ ) {
                        clients[i].write(data);
                }

    }).addListener("close", function () {

                // emitted when server or client closes connection
                sys.debug("close");
    });
  }).listen(8080);

  sys.debug("Listening on port 8080");


-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to