示例#1
0
 def setTimeout(self, second, param, *args, **kwargs):
     self.type = self.TIMER_ONCE
     self.second = second
     msg = MsgPack(Message.MSG_INNER_TIMER, param)
     uid = msg.get_param('userId')
     gid = msg.get_param('gameId')
     msg = MsgLine(msg.pack(), gid, target=uid).pack()
     task = self.tasklet(Message.to_inner(Message.MSG_INNER_TIMER), msg,
                         None).run
     self.timer = TaskManager.call_later(self.__timeout, second, msg, task,
                                         *args, **kwargs)
     return True
示例#2
0
 def setInterval(self, interval, param, delay=None, *args, **kwargs):
     self.type = self.TIMER_LOOP
     self.second = interval
     msg = MsgPack(Message.MSG_INNER_TIMER, param)
     uid = msg.get_param('userId')
     gid = msg.get_param('gameId')
     msg = MsgLine(msg.pack(), gid, target=uid).pack()
     task = self.tasklet(Message.to_inner(Message.MSG_INNER_TIMER), msg,
                         None).run
     if delay is None:
         self.timer = TaskManager.call_later(self.__timeout, self.second,
                                             msg, task, *args, **kwargs)
     else:
         self.timer = TaskManager.call_later(self.__timeout, delay, msg,
                                             task, *args, **kwargs)
     return True
示例#3
0
 def deliver_product(self, userId, gameId, orderId, orderInfo, productId,
                     payType):
     deliver_url = Context.Global.http_game() + '/v1/game/product/deliver'
     param = {
         'userId': userId,
         'gameId': gameId,
         'orderId': orderId,
         'productId': productId,
         'cost': int(orderInfo['cost']),
         'payType': payType,
         'channel': orderInfo['channel']
     }
     appKey = Context.Configure.get_game_item(gameId, 'appKey', '')
     data = '%s-%s-%s' % (orderId, appKey, productId)
     sign = Algorithm.md5_encode(data)
     param['sign'] = sign
     Context.Log.report('product.deliver: [%d, %d, %s, %s]' %
                        (userId, gameId, orderId, param))
     mo = MsgPack(0, param)
     result = Context.WebPage.wait_for_json(deliver_url, postdata=mo.pack())
     return 'error' not in result