Application

Methods

Method Description
Application.acceptConnection() accepts a connection to an application from a client
Application.broadcastMsg() broadcasts a message to all connected clients
Application.getStats() network statistics for the application instance
Application.disconnect() disconnects a client from the server
Application.shutdown() unloads the application instance

Properties

Property Description
Application.clients an object containing a list of all clients currently connected to the application
Application.hostname the host name of the server/vhost
Application.server the platform and version of the server
Application.name the name of the application instance

Event Handlers

Event handler Description
Application.onAppStart application is loaded by the server
Application.onAppStop application is unloaded by the server
Application.onConnect client connects to the application
Application.onDisconnect client disconnects from the application
Application.onError script error

Example

from rtmpy.services import Application

class DemoApplication(Application):

        def onAppStart(self):
               print 'Application %s started', self.name

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

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

        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()