Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from rtmpy import server
- from twisted.internet import reactor
- from twisted.python import log
- import sys
- class Client(server.Client):
- def async_server_call(self):
- from twisted.internet import defer, reactor
- d = defer.Deferred()
- reactor.callLater(0, d.callback, 'foobar')
- return d
- def makeClientCall(self):
- d = self.call('async_client_call', notify=True)
- def cb(result):
- if result == 'bazgak':
- self.call('server_succeed')
- return
- raise RuntimeError
- d.addCallback(cb)
- class Application(server.Application):
- client = Client
- def onConnectAccept(self, client, *args):
- client.makeClientCall()
- def standalone_run():
- log.startLogging(sys.stdout)
- reactor.listenTCP(1935, server.ServerFactory({'live': Application()}))
- if __name__=='__main__':
- reactor.callWhenRunning(standalone_run)
- reactor.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement