plugin XEP-0166: new trigger point + coroutines + helper methods:
- a new `XEP-0166_initiate` async trigger point is available - `initate` is now a coroutine - `jingleSessionInit` in applications and transports handlers are now called using `utils.adDeferred` - new `getApplication` helper method, to retrieve application from its namespace - new `getContentData` helper method to retrieve application and its argument from content
This commit is contained in:
parent
46c763cbf7
commit
aab9a8bf91
1 changed files with 72 additions and 42 deletions
|
|
@ -17,14 +17,8 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sat.core.i18n import _, D_
|
||||
from sat.core.constants import Const as C
|
||||
from sat.core import exceptions
|
||||
from sat.core.log import getLogger
|
||||
|
||||
log = getLogger(__name__)
|
||||
from sat.tools import xml_tools
|
||||
from sat.tools import stream
|
||||
import errno
|
||||
from zope import interface
|
||||
from twisted.words.xish import domish
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.internet import defer
|
||||
|
|
@ -33,8 +27,15 @@ from twisted.internet import endpoints
|
|||
from twisted.internet import reactor
|
||||
from twisted.internet import error
|
||||
from twisted.internet import interfaces
|
||||
from zope import interface
|
||||
import errno
|
||||
from sat.core.i18n import _, D_
|
||||
from sat.core.constants import Const as C
|
||||
from sat.core import exceptions
|
||||
from sat.core.log import getLogger
|
||||
from sat.tools import xml_tools
|
||||
from sat.tools import stream
|
||||
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
NS_STREAM = "http://salut-a-toi.org/protocol/stream"
|
||||
SECURITY_LIMIT = 30
|
||||
|
|
@ -193,10 +194,9 @@ class JingleStream(object):
|
|||
|
||||
def _streamOut(self, to_jid_s, profile_key):
|
||||
client = self.host.getClient(profile_key)
|
||||
return self.streamOut(client, jid.JID(to_jid_s))
|
||||
return defer.ensureDeferred(self.streamOut(client, jid.JID(to_jid_s)))
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def streamOut(self, client, to_jid):
|
||||
async def streamOut(self, client, to_jid):
|
||||
"""send a stream
|
||||
|
||||
@param peer_jid(jid.JID): recipient
|
||||
|
|
@ -207,7 +207,7 @@ class JingleStream(object):
|
|||
while True:
|
||||
endpoint = endpoints.TCP4ServerEndpoint(reactor, port)
|
||||
try:
|
||||
port_listening = yield endpoint.listen(factory)
|
||||
port_listening = await endpoint.listen(factory)
|
||||
except error.CannotListenError as e:
|
||||
if e.socketError.errno == errno.EADDRINUSE:
|
||||
port += 1
|
||||
|
|
@ -216,7 +216,8 @@ class JingleStream(object):
|
|||
else:
|
||||
factory.port_listening = port_listening
|
||||
break
|
||||
self._j.initiate(
|
||||
# we don't want to wait for IQ result of initiate
|
||||
defer.ensureDeferred(self._j.initiate(
|
||||
client,
|
||||
to_jid,
|
||||
[
|
||||
|
|
@ -226,8 +227,8 @@ class JingleStream(object):
|
|||
"app_kwargs": {"stream_object": factory},
|
||||
}
|
||||
],
|
||||
)
|
||||
defer.returnValue(str(port))
|
||||
))
|
||||
return str(port)
|
||||
|
||||
def jingleSessionInit(self, client, session, content_name, stream_object):
|
||||
content_data = session["contents"][content_name]
|
||||
|
|
|
|||
Loading…
Reference in a new issue