mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Trying to fix dead listeners with connection options
This commit is contained in:
@@ -34,7 +34,7 @@ var db = mongojs.connect('mydb');
|
||||
var crypto = require('crypto');
|
||||
|
||||
var port = 3000;
|
||||
var lists = [];
|
||||
var lists = {};
|
||||
var unique_ids = [];
|
||||
|
||||
server.listen(port, function () {
|
||||
@@ -507,17 +507,17 @@ io.on('connection', function(socket){
|
||||
|
||||
socket.on('disconnect', function()
|
||||
{
|
||||
left_channel(in_list, coll, guid, name, short_id);
|
||||
left_channel(coll, guid, name, short_id);
|
||||
});
|
||||
|
||||
socket.on('reconnect_failed', function()
|
||||
{
|
||||
left_channel(in_list, coll, guid, name, short_id);
|
||||
left_channel(coll, guid, name, short_id);
|
||||
});
|
||||
|
||||
socket.on('connect_timeout', function()
|
||||
{
|
||||
left_channel(in_list, coll, guid, name, short_id);
|
||||
left_channel(coll, guid, name, short_id);
|
||||
});
|
||||
|
||||
socket.on('pos', function()
|
||||
@@ -527,29 +527,26 @@ io.on('connection', function(socket){
|
||||
});
|
||||
});
|
||||
|
||||
function left_channel(in_list, coll, guid, name, short_id)
|
||||
function left_channel(coll, guid, name, short_id)
|
||||
{
|
||||
if(in_list)
|
||||
if(lists[coll] !== undefined && contains(lists[coll], guid))
|
||||
{
|
||||
var index = lists[coll].indexOf(guid);
|
||||
if(index != -1)
|
||||
{
|
||||
if(contains(lists[coll], guid))
|
||||
{
|
||||
var index = lists[coll].indexOf(guid);
|
||||
if(index != -1)
|
||||
{
|
||||
lists[coll].splice(index, 1);
|
||||
io.to(coll).emit("viewers", lists[coll].length);
|
||||
io.to(coll).emit('chat', [name, " left"]);
|
||||
}
|
||||
}
|
||||
|
||||
if(contains(unique_ids, short_id))
|
||||
{
|
||||
var index = unique_ids.indexOf(guid);
|
||||
if(index != -1)
|
||||
lists[coll].splice(index, 1);
|
||||
}
|
||||
|
||||
lists[coll].splice(index, 1);
|
||||
io.to(coll).emit("viewers", lists[coll].length);
|
||||
io.to(coll).emit('chat', [name, " left"]);
|
||||
}
|
||||
}
|
||||
|
||||
if(contains(unique_ids, short_id))
|
||||
{
|
||||
var index = unique_ids.indexOf(guid);
|
||||
if(index != -1)
|
||||
lists[coll].splice(index, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function del(params, socket)
|
||||
|
||||
4
static/dist/main-min.js
vendored
4
static/dist/main-min.js
vendored
File diff suppressed because one or more lines are too long
@@ -36,7 +36,12 @@ var lastSample = Date.now();
|
||||
var began = false;
|
||||
var id;
|
||||
|
||||
var socket = io.connect('//'+window.location.hostname+':3000');
|
||||
var connection_options = {
|
||||
'sync disconnect on unload':true,
|
||||
transports: ['websocket', 'xhr-polling', 'polling', 'htmlfile', 'flashsocket']
|
||||
};
|
||||
|
||||
var socket = io.connect('//'+window.location.hostname+':3000', connection_options);
|
||||
socket.on("get_list", function(){
|
||||
socket.emit('list', chan.toLowerCase());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user