NetConnection

Methods

Method Description
NetConnection.addHeader() adds a context header
NetConnection.call() invokes a method or operation on a remote server
NetConnection.close() closes a server connection
NetConnection.connect() connects to an application server or other RTMP server

Properties

Property Description
NetConnection.uri the URI that the NetConnection.connect() method passed

Event Handlers

Event handler Description
NetConnection.onStatus called when there is a change in connection status

Example

from rtmpy.services import Application, NetConnection

class DemoApplication(Application):

        def onAppStart(self):
               print 'Application %s started', self.name
               nc = NetConnection()
               nc.connect('rtmp://localhost/myApp')

        def onAppStop(self):
               print 'Application on %s stopped', self.hostname
               nc.close()

        def onConnect(self, client):
               print 'Client connected:', client.ip
               nc.call('helloWorld')

        def onDisconnect(self, client):
              print 'Client disconnected:', client.ip

def run_demo():
        server = DemoApplication('RTMPyDemo')
        reactor.listenTCP(1935, server, 50, 'localhost')
        reactor.run()

if __name__ == '__main__':
        run_demo()