def playerDisconnected(self,player): if player == None: return messagePlayerDisconnected = MessageWriter() messagePlayerDisconnected.writeByte(MESSAGE_PLAYER_DISCONNECTED) messagePlayerDisconnected.writeInt(player.playerID) # Notify the other players that the player disconnected if player.room and len(player.room.players) > 0: for p in player.room.players: if p != player: p.protocol.sendMessage(messagePlayerDisconnected)
def playerCon(self,player): self.openLog() print "CONNECTED " +str(len(player.room.players)) # Close the room at 2 if(len(player.room.players) == 2): print "Chat started in " + player.room.roomID player.room.open = False # Tell players its time to chat messageChatStart = MessageWriter() messageChatStart.writeByte(MESSAGE_BEGIN_CHAT) messageChatStart.writeInt(1) for p in player.room.players: p.protocol.sendMessage(messageChatStart)