raise GameError('target user offline')
raise GameError('can only query with registered nicknames')
cmd_QUERY.argtypes = 'string string'
+
+def cmd_PING(game, connection_id):
+ game.io.send('PONG')
+cmd_QUERY.argtypes = ''
from plomrogue.tasks import Task_WAIT, Task_MOVE, Task_WRITE
from plomrogue.errors import GameError
-from plomrogue.commands import cmd_ALL, cmd_LOGIN, cmd_QUERY
+from plomrogue.commands import cmd_ALL, cmd_LOGIN, cmd_QUERY, cmd_PING
from plomrogue.io import GameIO
from plomrogue.misc import quote
from plomrogue.things import Thing, ThingPlayer
self.map_geometry = MapGeometrySquare(YX(24, 40))
self.commands = {'QUERY': cmd_QUERY,
'ALL': cmd_ALL,
- 'LOGIN': cmd_LOGIN}
+ 'LOGIN': cmd_LOGIN,
+ 'PING': cmd_PING}
self.thing_type = Thing
self.thing_types = {'player': ThingPlayer}
self.sessions = {}
tui.log_msg('game error: ' + tokens[1]);
} else if (tokens[0] === 'GAME_ERROR') {
tui.log_msg('game error: ' + tokens[1]);
+ } else if (tokens[0] === 'PONG') {
+ console.log('PONG');
} else {
tui.log_msg('unhandled input: ' + event.data);
}
}
+
+window.setInterval(function() { websocket.send('PING') }, 30000);
</script>
</body>
</html>