def _on_message(self, msg): cmd, size, string = self.receive(msg) print 'cmd:', cmd print 'string:', string if cmd == ENTER_ROOM: sleep(10) proto = game_pb2.ReadyRequest() self.send(proto, READY) print '准备' elif cmd == READY: print '以上玩家准备' # elif cmd == POKER_DEAL: # proto = game_pb2.CockDealResponse() # proto.ParseFromString(string) # self.cards = [] # for a in proto.cards_in_hand: # self.cards.append(a.card) # print '发牌' elif cmd == ENTER_ROOM_OTHER: print '其他玩家进入房间' else: print 'else cmd'
def ready(string, session): # print 'ready' proto = game_pb2.ReadyRequest() proto.ParseFromString(string) player = SessionMgr().player(session) player.machine.cur_state.execute(player, "ready", proto)