node-browserchannel icon indicating copy to clipboard operation
node-browserchannel copied to clipboard

Message not sent when connection immediately closed

Open web3d0 opened this issue 11 years ago • 1 comments

Example ported to connect 3, issue may be within connect library?

chat.html:

socket = new BCSocket('/channel');
socket.onopen = function() {
    socket.send({hi:'there'});
    socket.close();
};

chat.js:

var connect = require('connect');
var http = require('http');
var browserChannel = require('browserchannel').server;
var serveStatic = require('serve-static');
var app = connect();
app.use(serveStatic(__dirname));
app.use(browserChannel(function (session) {
    console.log('New session: ' + session.id +
        ' from ' + session.address +
        ' with cookies ' + session.headers.cookie);
    session.on('message', function (data) {
        console.log(session.id + ' sent ' + JSON.stringify(data));
        session.send(data);
    });

etc

socket.close() in chat.html needs to be commented out for hi:"there" message to get through.

web3d0 avatar Jan 06 '15 09:01 web3d0

I would imagine the example chatserver was written assuming connect 1.7.2. Browserchannel is currently tested against express 4.

wenzowski avatar Feb 23 '15 23:02 wenzowski