Adding on error for socket to try to handle disconnect

This commit is contained in:
Kasper Rynning-Tønnesen
2015-07-08 01:12:47 +02:00
parent 21a1788d07
commit a60789ca2f
3 changed files with 13 additions and 2 deletions

View File

@@ -57,6 +57,10 @@ io.on('connection', function(socket){
var guid = hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]); var guid = hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]);
socket.on('close', function() {
console.log("closing socket");
})
socket.on('ping', function() { socket.on('ping', function() {
socket.emit("ok"); socket.emit("ok");
}); });
@@ -524,6 +528,11 @@ io.on('connection', function(socket){
left_channel(coll, guid, name, short_id); left_channel(coll, guid, name, short_id);
}); });
socket.on('error', function()
{
left_channel(coll, guid, name, short_id);
});
socket.on('pos', function() socket.on('pos', function()
{ {
check_inlist(coll, guid, socket, name); check_inlist(coll, guid, socket, name);
@@ -533,6 +542,7 @@ io.on('connection', function(socket){
function left_channel(coll, guid, name, short_id) function left_channel(coll, guid, name, short_id)
{ {
if(coll == undefined || guid == undefined) console.log(coll, guid)
if(lists[coll] !== undefined && contains(lists[coll], guid)) if(lists[coll] !== undefined && contains(lists[coll], guid))
{ {
var index = lists[coll].indexOf(guid); var index = lists[coll].indexOf(guid);

File diff suppressed because one or more lines are too long

View File

@@ -36,6 +36,7 @@ var Search = {
url: yt_url, url: yt_url,
dataType:"jsonp", dataType:"jsonp",
success: function(response){ success: function(response){
console.log(response.items.length);
if(response.items){ if(response.items){
//get list of IDs and make new request for video info //get list of IDs and make new request for video info
$.each(response.items, function(i,data) $.each(response.items, function(i,data)