plugin room_game, radiocol: RoomGame.send returns a Deferred.
This commit is contained in:
parent
3de25fd781
commit
7c29b8c566
1 changed files with 16 additions and 13 deletions
|
|
@ -22,7 +22,7 @@ from logging import debug, info, warning, error
|
|||
from twisted.words.xish import domish
|
||||
from twisted.internet import reactor
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.internet import threads, defer
|
||||
from twisted.internet import defer
|
||||
from sat.core import exceptions
|
||||
import os.path
|
||||
import copy
|
||||
|
|
@ -89,7 +89,9 @@ class Radiocol(object):
|
|||
"""This method is called by libervia when a song has been uploaded
|
||||
@param referee: JID of the referee in the room (room userhost + '/' + nick)
|
||||
@song_path: absolute path of the song added
|
||||
@param profile_key: %(doc_profile_key)s"""
|
||||
@param profile_key: %(doc_profile_key)s
|
||||
@return: a Deferred instance
|
||||
"""
|
||||
#XXX: this is a Q&D way for the proof of concept. In the future, the song should
|
||||
# be streamed to the backend using XMPP file copy
|
||||
# Here we cheat because we know we are on the same host, and we don't
|
||||
|
|
@ -111,14 +113,7 @@ class Radiocol(object):
|
|||
}
|
||||
radio_data = self.games[jid.JID(referee).userhost()] # FIXME: referee comes from Libervia's client side, it's unsecure
|
||||
radio_data['to_delete'][attrs['filename']] = song_path # FIXME: works only because of the same host trick, see the note under the docstring
|
||||
|
||||
# XXX: avoid deferToThread which is causing testing troubles. When using deferToThread,
|
||||
# the callbacks that are added (by the test) to the Deferred instance returned by this
|
||||
# method are not run. And if you run d.callback again, you get a AlreadyCalledError.
|
||||
d = defer.Deferred()
|
||||
d.addCallback(self.send, ('', 'song_added'), attrs, profile=profile)
|
||||
d.callback(jid.JID(referee))
|
||||
return d
|
||||
return self.send(jid.JID(referee), ('', 'song_added'), attrs, profile=profile)
|
||||
|
||||
def playNext(self, room_jid, profile):
|
||||
""""Play next song in queue if exists, and put a timer
|
||||
|
|
|
|||
Loading…
Reference in a new issue