Ejemplo n.º 1
0
 def setup(self, interval, action, msgPackParams, cancelLastTimer=True):
     '''
     启动计时器
     interval 倒计时的时间, 单位: 秒
     action table_call命令下(params中)的action值
     msgPackParams 传递的其他的参数数据集合dict, 可以在doTableCall中的msg中使用msg.getParam(key)来取得其中的参数
     '''
     if self._fttimer and cancelLastTimer:
         self._fttimer.cancel()
     self._interval = interval
     userId = msgPackParams.get('userId', 0)
     clientId = msgPackParams.get('clientId', None)
     assert (isinstance(userId, int))
     assert (isinstance(action, (unicode, str)))
     if clientId != None:
         assert (isinstance(clientId, (unicode, str)))
     msg = MsgPack()
     msg.updateParam(msgPackParams)
     msg.setCmdAction('table_call', action)
     msg.setParam('gameId', self._table.gameId)
     msg.setParam('roomId', self._table.roomId)
     msg.setParam('tableId', self._table.tableId)
     msg.setParam('userId', userId)
     msg.setParam('clientId', clientId)
     self._fttimer = FTTimer(interval, self._onTimeOut, msg, pack=msg)
Ejemplo n.º 2
0
 def setup(self, interval, action, msgPackParams, cancelLastTimer=True):
     '''
     启动计时器
     interval 倒计时的时间, 单位: 秒
     action table_call命令下(params中)的action值
     msgPackParams 传递的其他的参数数据集合dict, 可以在doTableCall中的msg中使用msg.getParam(key)来取得其中的参数
     '''
     if self._fttimer and cancelLastTimer:
         self._fttimer.cancel()
     self._interval = interval
     userId = msgPackParams.get('userId', 0)
     clientId = msgPackParams.get('clientId', None)
     assert (isinstance(userId, int))
     assert (isinstance(action, (unicode, str)))
     if clientId != None:
         assert (isinstance(clientId, (unicode, str)))
     msg = MsgPack()
     msg.updateParam(msgPackParams)
     msg.setCmdAction('table_call', action)
     msg.setParam('gameId', self._table.gameId)
     msg.setParam('roomId', self._table.roomId)
     msg.setParam('tableId', self._table.tableId)
     msg.setParam('userId', userId)
     msg.setParam('clientId', clientId)
     self._fttimer = FTTimer(interval, self._onTimeOut, msg)
Ejemplo n.º 3
0
 def makeTableManageReq(cls, userId, shadowRoomId, tableId, clientId, action, params=None):
     mpReq = MsgPack()
     mpReq.setCmd("table_manage")
     mpReq.setParam("action", action)
     mpReq.setParam("userId", userId)
     mpReq.setParam("gameId", strutil.getGameIdFromInstanceRoomId(shadowRoomId))
     mpReq.setParam("roomId", shadowRoomId)
     mpReq.setParam("tableId", tableId)
     mpReq.setParam("clientId", clientId)
     if params:
         mpReq.updateParam(params)
     if ftlog.is_debug():
         ftlog.debug(str(mpReq), caller=cls)
     return mpReq
Ejemplo n.º 4
0
 def makeTableManageReq(cls,
                        userId,
                        shadowRoomId,
                        tableId,
                        clientId,
                        action,
                        params=None):
     mpReq = MsgPack()
     mpReq.setCmd("table_manage")
     mpReq.setParam("action", action)
     mpReq.setParam("userId", userId)
     mpReq.setParam("gameId",
                    strutil.getGameIdFromInstanceRoomId(shadowRoomId))
     mpReq.setParam("roomId", shadowRoomId)
     mpReq.setParam("tableId", tableId)
     mpReq.setParam("clientId", clientId)
     if params:
         mpReq.updateParam(params)
     if ftlog.is_debug():
         ftlog.debug(str(mpReq), caller=cls)
     return mpReq