예제 #1
0
    def test_create_unicode(self):
        """
        Test initial args for L{server.ServerFactory}
        """
        self.factory = server.ServerFactory({'дак': self.app})

        self.assertEqual(self.factory.applications, {'дак': self.app})

        d = self.app.ret = defer.Deferred()

        self.factory = server.ServerFactory({'дак': self.app})

        self.assertEqual(self.factory.applications, {})

        def cb(res):
            self.assertEqual(self.factory.applications, {'дак': self.app})

        reactor.callLater(0, d.callback, None)
예제 #2
0
    def setUp(self):
        self.factory = server.ServerFactory()
        self.protocol = self.factory.buildProtocol(None)
        self.transport = StringTransportWithDisconnection()
        self.nc = server.NetConnection(self.protocol)

        self.protocol.makeConnection(self.transport)
        self.transport.protocol = self.protocol
        self.protocol.versionReceived(3)
        self.protocol.handshakeSuccess('')

        self.manager = self.protocol.streamManager
예제 #3
0
    def setUp(self):
        self.file = StringIOWithoutClosing()
        self.transport = protocol.FileWrapper(self.file)

        self.factory = server.ServerFactory()
        self.protocol = self.factory.buildProtocol(None)

        self.protocol.factory = self.factory

        self.protocol.transport = self.transport
        self.protocol.connectionMade()
        self.protocol.versionSuccess()
        self.protocol.handshakeSuccess('')

        self.messages = []

        def send_message(*args):
            self.messages.append(args)

        self.patch(self.protocol.nc, 'sendMessage', send_message)

        self.control = self.protocol.controlStream
예제 #4
0
        client.call("initial", [ "connection attempt received", args ])
        print(args)
        return True

    def onConnectAccept(self, client, **args):
        print("Connection accepted", client)
        client.call("welcome", [ "You have connected!", args ])
        return True

    def onDownstreamBandwidth(self, interval, bandwidth):
        print("Downstream Bandwidth:", interval, bandwidth)
        return True

    def echo(self, *args, **kw):
        print("echo", args, kw)
        return args

    def onDisconnect(self, client):
	# This is probably never actually sent.
	client.call("disconnected", "arg1");
        return True;


app = LiveApplication()

reactor.listenTCP(9984, server.ServerFactory({
    'rtmpyecho': app
}))

reactor.run()
예제 #5
0
파일: server.py 프로젝트: vanzhiganov/rtmpy
from rtmpy import server

from twisted.internet import reactor


class LiveApplication(server.Application):
    """
    The simplest application possible.
    """


app = LiveApplication()

reactor.listenTCP(1935, server.ServerFactory({
    'live': app,
    'oflaDemo': app # provides default support for the red5 publisher swf
}))

reactor.run()
예제 #6
0
 def setUp(self):
     self.factory = server.ServerFactory()
     self.app = SimpleApplication()