def onholepunchingok(self, peer, packet): game = player = None for _game in self.games: for _player in _game.players: if _player.address == peer.address: game = _game player = _player break if game is None: self.send( peer, packets.cmd_fatalerror("Unable to find the game you're in")) self.disconnect(peer, True) return player.ready = True logging.debug("[HOLEPUNCHING] [%s] Player %s (%s) is ready" % (game.uuid, player.name, player.address)) playersready = True for _player in game.players: if not _player.ready: playersready = False break if playersready: self.call_callbacks("startgame", game)
def onreceive(self, event): #logging.debug("[RECEIVE] Got data from %s" % (event.peer.address)) packet = packets.unserialize(event.packet.data) if packet is None: logging.warning("Unknown packet from %s!" % (event.peer.address)) self.send(event.peer, packets.cmd_fatalerror("Unknown packet. Maybe old client?")) self.disconnect(event.peer, True) return if not packet.__class__ in self.callbacks: logging.warning("Unhandled network packet from %s!" % (event.peer.address)) return self.call_callbacks(packet.__class__, event.peer, packet)
def onholepunchingok(self, peer, packet): game = player = None for _game in self.games: for _player in _game.players: if _player.address == peer.address: game = _game player = _player break if game is None: self.send(peer, packets.cmd_fatalerror("Unable to find the game you're in")) self.disconnect(peer, True) return player.ready = True logging.debug("[HOLEPUNCHING] [%s] Player %s (%s) is ready" % (game.uuid, player.name, player.address)) playersready = True for _player in game.players: if not _player.ready: playersready = False break if playersready: self.call_callbacks("startgame", game)
def _fatalerror(self, peer, message, later=True): self.send(peer, packets.cmd_fatalerror(message)) self.disconnect(peer, later)
def _fatal_error(self, peer: 'enet.Peer', message: Text): """ Send an error message to a client and disconnect. """ self.send(peer, packets.cmd_fatalerror(message)) self.disconnect(peer, later=True)