client: add disconnected/reconnected messages into PM windows

This commit is contained in:
mappu 2017-02-05 19:43:23 +13:00
parent 3c2f0c7368
commit 7b5dbde7a6

View File

@ -207,6 +207,12 @@ var write = function(tab) {
}; };
}; };
var write_system_message_in_all_pm_tabs = function(system_message) {
for (var k in pm_tabs) {
writerFor(k).system(system_message);
}
};
/* Userlist */ /* Userlist */
var switchToPM = function(u) { var switchToPM = function(u) {
@ -984,6 +990,7 @@ window.onload = function() {
}); });
sock.on('hello', function() { sock.on('hello', function() {
transition(STATE_ACTIVE); transition(STATE_ACTIVE);
write_system_message_in_all_pm_tabs("Reconnected.");
}); });
sock.on('part', function(u) { sock.on('part', function(u) {
userlist.del(u.user); userlist.del(u.user);
@ -1020,10 +1027,12 @@ window.onload = function() {
sock.on('close', function() { sock.on('close', function() {
transition(STATE_DISCONNECTED); transition(STATE_DISCONNECTED);
write("tab-main").system("Connection closed by remote host."); write("tab-main").system("Connection closed by remote host.");
write_system_message_in_all_pm_tabs("Disconnected.");
}); });
sock.on('disconnect', function() { sock.on('disconnect', function() {
transition(STATE_DISCONNECTED); transition(STATE_DISCONNECTED);
write("tab-main").system("Lost connection to the server."); write("tab-main").system("Lost connection to the server.");
write_system_message_in_all_pm_tabs("Disconnected.");
}); });
sock.on('usercommand', function(data) { sock.on('usercommand', function(data) {
process_usercommand(data); process_usercommand(data);