Setup sending chats and users to the client
This commit is contained in:
parent
31ab993699
commit
87207647e0
24
main.js
24
main.js
|
@ -437,23 +437,35 @@ var server = net.createServer(function(socket)
|
||||||
var chat_keys = Object.keys(chats);
|
var chat_keys = Object.keys(chats);
|
||||||
var chats_client = {};
|
var chats_client = {};
|
||||||
|
|
||||||
// Loop over them
|
// Get a list of user keys
|
||||||
|
var user_keys = Object.keys(users);
|
||||||
|
var users_client = {};
|
||||||
|
|
||||||
|
// Loop over the chats
|
||||||
for(var i=0;i<chat_keys.length;i++)
|
for(var i=0;i<chat_keys.length;i++)
|
||||||
{
|
{
|
||||||
// Register the key to the temporary varible
|
// Register the key to the temporary varible
|
||||||
chats_client[chat_keys[i]] = new Object();
|
chats_client[chat_keys[i]] = new Object();
|
||||||
|
|
||||||
// Set the chat name
|
// Set the chat data
|
||||||
chats_client[chat_keys[i]].name = chats[chat_keys[i]].name;
|
chats_client[chat_keys[i]].name = chats[chat_keys[i]].name;
|
||||||
chats_client[chat_keys[i]].messages = chat[chat_keys[i]].messages;
|
chats_client[chat_keys[i]].messages = chat[chat_keys[i]].messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Sending list of chats");
|
// Loop over the users
|
||||||
|
for(var i=0;i<user_keys.length;i++)
|
||||||
|
{
|
||||||
|
// Register the key to the temporary varible
|
||||||
|
users_client[user_keys[i]] = new Object();
|
||||||
|
}
|
||||||
|
|
||||||
// Send the list of chats
|
console.log("Sending server data");
|
||||||
|
|
||||||
|
// Send the server data
|
||||||
socket_write(sock, {
|
socket_write(sock, {
|
||||||
mode: "chat_list",
|
mode: "login",
|
||||||
chats: chats_client
|
chats: chats_client,
|
||||||
|
users: users_client
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue