def __init__(self, sock, server, game): Connection.__init__(self, sock, server) self.game=game self.player=None self._encoder = encoder('plaintext') # client commands self._commands = { 'SET': self._set_prop, "LOGIN": self.game.login, "LOGOUT": self.game.logout, "PING": self.ping, "PLAYERINFO": self.game.playerinfo, "NEWUSER": self.game.NewUser, "LIST_OF_ENTITIES": self.game.list_of_entities, "ENTINFO": self.game.entity_info, "ENTACTION": self.game.EntAction, "TYPEINFO": entity.typeinfo, "PLAYERS": self.game.Players, "QUIT": self.game.logout } # properties self._props = { 'ENCODER': self._set_encoder }
def __init__(self, sock, server, game): Connection.__init__(self, sock, server) self.game = game self.player = None self._encoder = encoder('plaintext') # client commands self._commands = { 'SET': self._set_prop, "LOGIN": self.game.login, "LOGOUT": self.game.logout, "PING": self.ping, "PLAYERINFO": self.game.playerinfo, "NEWUSER": self.game.NewUser, "LIST_OF_ENTITIES": self.game.list_of_entities, "ENTINFO": self.game.entity_info, "ENTACTION": self.game.EntAction, "TYPEINFO": entity.typeinfo, "PLAYERS": self.game.Players, "QUIT": self.game.logout } # properties self._props = {'ENCODER': self._set_encoder}
def disconnect(self, message='Disconnected'): """ Force a client to disconnect. """ # notify client self.game.unicast(self, 'DISCONNECTED', message) # actual disconnect Connection.disconnect(self, message)
def peer(self): if self.player: return str(Connection.peer(self)) + '::' + self.player.name else: return str(Connection.peer(self))