2011-12-25 03:37:45 +00:00
|
|
|
/**
|
|
|
|
* Event handlers from long-poll operations.
|
|
|
|
*
|
|
|
|
* @author ajanata
|
|
|
|
*/
|
|
|
|
|
|
|
|
cah.longpoll.ErrorCodeHandlers.not_registered = function(data) {
|
|
|
|
cah.longpoll.Resume = false;
|
|
|
|
// TODO disable interface
|
|
|
|
cah.log.error("The server seems to have restarted. Any in-progress games have been lost.");
|
|
|
|
cah.log.error("You will need to refresh the page to start a new game.");
|
|
|
|
};
|
|
|
|
|
|
|
|
cah.longpoll.EventHandlers.new_player = function(data) {
|
2012-01-12 21:07:19 +00:00
|
|
|
// don't display our own join
|
|
|
|
if (data.nickname != cah.nickname) {
|
|
|
|
cah.log.status(data.nickname + " has connected.");
|
|
|
|
}
|
2011-12-25 03:37:45 +00:00
|
|
|
};
|
|
|
|
|
2012-01-06 23:53:04 +00:00
|
|
|
cah.longpoll.EventHandlers.player_leave = function(data) {
|
|
|
|
var friendly_reason = "Leaving";
|
|
|
|
// see net.socialgamer.cah.data.User.DisconnectReason
|
|
|
|
switch (data.reason) {
|
|
|
|
case "MANUAL":
|
|
|
|
friendly_reason = "Leaving";
|
|
|
|
break;
|
|
|
|
case "PING_TIMEOUT":
|
|
|
|
friendly_reason = "Ping timeout";
|
|
|
|
break;
|
|
|
|
case "KICKED":
|
|
|
|
friendly_reason = "Kicked by server";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cah.log.status(data.nickname + " has disconnected (" + friendly_reason + ").");
|
|
|
|
};
|
|
|
|
|
2011-12-25 03:37:45 +00:00
|
|
|
cah.longpoll.EventHandlers.noop = function(data) {
|
|
|
|
// pass
|
|
|
|
};
|
|
|
|
|
|
|
|
cah.longpoll.EventHandlers.chat = function(data) {
|
|
|
|
// TODO deal with multiple channels eventually
|
|
|
|
// don't display our own chat
|
|
|
|
if (data.from != cah.nickname) {
|
|
|
|
cah.log.status("<" + data.from + "> " + data.message);
|
|
|
|
}
|
|
|
|
};
|