当前位置: 首页>>代码示例>>Python>>正文


Python Deferred.notifying方法代码示例

本文整理汇总了Python中twisted.internet.defer.Deferred.notifying方法的典型用法代码示例。如果您正苦于以下问题:Python Deferred.notifying方法的具体用法?Python Deferred.notifying怎么用?Python Deferred.notifying使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.defer.Deferred的用法示例。


在下文中一共展示了Deferred.notifying方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tell

# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import notifying [as 别名]
 def tell(self, about, receivers, command, **kwargs):
     """send info about player 'about' to users 'receivers'"""
     def encodeKwargs():
         """those values are classes like Meld, Tile etc.
            Convert to str(python2) or bytes(python3"""
         for keyword in ('tile', 'tiles', 'meld', 'melds'):
             if keyword in kwargs:
                 kwargs[keyword] = str(kwargs[keyword]).encode()
     encodeKwargs()
     if about.__class__.__name__ == 'User':
         about = self.playerForUser(about)
     if not isinstance(receivers, list):
         receivers = list([receivers])
     assert receivers, 'DeferredBlock.tell(%s) has no receiver' % command
     self.__enrichMessage(self.table.game, about, command, kwargs)
     aboutName = about.name if about else None
     if self.table.running and len(receivers) in [1, 4]:
         # messages are either identical for all 4 players
         # or identical for 3 players and different for 1 player. And
         # we want to capture each message exactly once.
         self.table.game.appendMove(about, command, kwargs)
     localDeferreds = []
     for rec in self.__convertReceivers(receivers):
         isClient = rec.__class__.__name__.endswith('Client')
         if Debug.traffic and not isClient:
             message = u'-> {receiver:<15} about {about} {command}{kwargs}'.format(
                 receiver=rec.name[:15], about=about, command=command,
                 kwargs=Move.prettyKwargs(kwargs))
             logDebug(message)
         if isClient:
             defer = Deferred()
             defer.addCallback(rec.remote_move, command, **kwargs)
         else:
             defer = self.table.server.callRemote(
                 rec,
                 'move',
                 aboutName,
                 command.name,
                 **kwargs)
         if defer:
             defer.command = command.name
             defer.notifying = 'notifying' in kwargs
             self.__addRequest(defer, rec, about)
         else:
             msg = m18nE('The game server lost connection to player %1')
             self.table.abort(msg, rec.name)
         if isClient:
             localDeferreds.append(defer)
     for defer in localDeferreds:
         defer.callback(aboutName)  # callback needs an argument !
开发者ID:KDE,项目名称:kajongg,代码行数:52,代码来源:deferredutil.py


注:本文中的twisted.internet.defer.Deferred.notifying方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。