Beispiel #1
0
class HelloClientProtocol(Protocol):
    def connectionMade(self):
        print("connectionMade", self.transport.getHost(),
              self.transport.getPeer())
        self.transport.write('hello' * 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 WrappingWebSocketClientFactory

    log.startLogging(sys.stdout)

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

    reactor.connectTCP("127.0.0.1", 9000, factory)
    reactor.run()
 def connect(self, protocolFactory):
     return self._endpoint.connect(WrappingWebSocketClientFactory(protocolFactory, reactor=self._reactor, **self._options))
Beispiel #3
0
   def connectionMade(self):
      print("connectionMade", self.transport.getHost(), self.transport.getPeer())
      self.transport.write('hello' * 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 WrappingWebSocketClientFactory

   log.startLogging(sys.stdout)

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

   reactor.connectTCP("127.0.0.1", 9000, factory)
   reactor.run()