コード例 #1
0
ファイル: servertable.py プロジェクト: zero804/kajongg
 def collectVoiceData(self, requests):
     """collect voices of other players"""
     if not self.running:
         return
     block = DeferredBlock(self)
     voiceDataRequests = []
     for request in requests:
         if request.answer == Message.ClientWantsVoiceData:
             # another human player requests sounds for voiceId
             voiceId = request.args[0]
             voiceFor = [
                 x for x in self.game.players
                 if isinstance(self.remotes[x], User)
                 and self.remotes[x].voiceId == voiceId
             ][0]
             voiceFor.voice = Voice(voiceId)
             if Debug.sound:
                 logDebug('client %s wants voice data %s for %s' %
                          (request.user.name, request.args[0], voiceFor))
             voiceDataRequests.append((request.user, voiceFor))
             if not voiceFor.voice.oggFiles():
                 # the server does not have it, ask the client with that
                 # voice
                 block.tell(voiceFor, voiceFor,
                            Message.ServerWantsVoiceData)
     block.callback(self.sendVoiceData, voiceDataRequests)
コード例 #2
0
 def clientAction(self, dummyClient, move):
     """server sent us voice sounds about somebody else"""
     move.player.voice = Voice(move.md5sum, move.source)
     if Debug.sound:
         logDebug(
             '%s gets voice data %s from server, language=%s' %
             (move.player, move.player.voice, move.player.voice.language()))