Beispiel #1
0
    def __init__(self, wrappedFactory, jsonEncoder=None, jsonDecoder=None,
                 reactor=None,
                 enableCompression=True,
                 autoFragmentSize=0,
                 subprotocol=None,
                 debug=False):

        sockJSWrappedFactory = WebSocketWrappingFactory(
            wrappedFactory)
        WrappingWebSocketServerFactory.__init__(
            self,
            sockJSWrappedFactory,
            url=None,
            reactor=reactor,
            enableCompression=enableCompression,
            autoFragmentSize=autoFragmentSize,
            subprotocol=subprotocol,
            debug=debug)
 def listen(self, protocolFactory):
     return self._endpoint.listen(WrappingWebSocketServerFactory(protocolFactory, reactor=self._reactor, **self._options))
Beispiel #3
0
class HelloServerProtocol(Protocol):

    def connectionMade(self):
        print("connectionMade", self.transport.getHost(), self.transport.getPeer())
        self.transport.write('how are you?' * 100)

    def dataReceived(self, data):
        print("dataReceived: {}".format(data))


if __name__ == '__main__':

    import sys

    from twisted.python import log
    from twisted.internet import reactor
    from twisted.internet.protocol import Factory

    from autobahn.twisted.websocket import WrappingWebSocketServerFactory

    log.startLogging(sys.stdout)

    wrappedFactory = Factory.forProtocol(HelloServerProtocol)
    factory = WrappingWebSocketServerFactory(wrappedFactory,
                                             "ws://127.0.0.1:9000",
                                             enableCompression=False,
                                             autoFragmentSize=1024)

    reactor.listenTCP(9000, factory)
    reactor.run()
Beispiel #4
0
    def connectionMade(self):
        print("connectionMade", self.transport.getHost(),
              self.transport.getPeer())
        self.transport.write('how are you?' * 100)

    def dataReceived(self, data):
        print("dataReceived: {}".format(data))


if __name__ == '__main__':

    import sys

    from twisted.python import log
    from twisted.internet import reactor
    from twisted.internet.protocol import Factory

    from autobahn.twisted.websocket import WrappingWebSocketServerFactory

    log.startLogging(sys.stdout)

    wrappedFactory = Factory.forProtocol(HelloServerProtocol)
    factory = WrappingWebSocketServerFactory(wrappedFactory,
                                             "ws://localhost:9000",
                                             debug=False,
                                             enableCompression=False,
                                             autoFragmentSize=1024)

    reactor.listenTCP(9000, factory)
    reactor.run()