socket.io-client的范围

时间:2014-12-22 20:49:42

标签: node.js socket.io

是否需要使用socket_lifetime_protector数组。套接字是否在功能范围之外被销毁。

var socket_lifetime_protector = []; // Is this necessary to protect the lifetime of socket

function createNewSocket(username)
{
    var socket = require('socket.io-client')('http://localhost:3000');

    socket_lifetime_protector.push(socket); // Is this required

    socket.on('some_signal', function() {...});
}

0 个答案:

没有答案