(想要更新一个新客户端,该客户端使用迄今为止创建的所有聊天室列表登录)
假设我做这样的事情:(每次有人加入应用程序时)
socket.emit('updateClient', rooms);
rooms
是一个对象,由一个对象的许多room
实例组成,该Room
对象本身很小,但具有相当大的代码prototype
作为room
示例rooms
:
var rooms = {}; // contain all "Room" instances
..
..
// 'room' will create new instance for every "room" created
var room= new Room();
// save reference in `rooms`
rooms[room.id] = room;
..
var Room = function(){
this.id = RANDOM NUMBER
this.people = []; // an array of people in the room
}
Room.prototype = {
...
A LOT OF INNER FUNCTIONS
THAT ARE IRRELEVANT TO THE CLIENT
...
}
我的问题是:
原型会发送给客户吗?(不希望这样)并且它会以我这样做的方式使套接字请求“沉重”吗?