(would like to update a new client that logs in with a list of all chat rooms that were created so far)
Say I do something like this: (every time a person joins the app)
socket.emit('updateClient', rooms);
rooms
is an object, consisting of many room
instances of a Room
object which is by itself small, but has a pretty big code as a prototype
of room
Example of 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
...
}
My question is:
would the prototyped be sent along to the client? (wouldn't want that) and would it make the socket request "heavy" in the way I'm doing this?