Beispiel #1
0
    # create a WAMP application session factory
    ##
    from autobahn.twisted.wamp import ApplicationSessionFactory
    session_factory = ApplicationSessionFactory()

    # .. and set the session class on the factory
    ##
    session_factory.session = MyAppComponent

    # since we are running this component as a client, there
    # will be only 1 app session instance anyway. We'll store a
    # reference on the session factory, so we can access it
    # from "outside" the session instance later (see below)
    ##
    session_factory._myAppSession = None

    # create a WAMP-over-WebSocket transport client factory
    ##
    from autobahn.twisted.websocket import WampWebSocketClientFactory
    transport_factory = WampWebSocketClientFactory(session_factory, "ws://127.0.0.1:8080/ws")

    # start a WebSocket client from an endpoint
    ##
    client = clientFromString(reactor, "tcp:127.0.0.1:8080")
    client.connect(transport_factory)

    # publish an event every second from the (single) application session
    # that get created by the session factory
    ##
    @inlineCallbacks
Beispiel #2
0
   ##
   from autobahn.twisted.wamp import ApplicationSessionFactory
   session_factory = ApplicationSessionFactory()


   ## .. and set the session class on the factory
   ##
   session_factory.session = MyAppComponent


   ## since we are running this component as a client, there
   ## will be only 1 app session instance anyway. We'll store a
   ## reference on the session factory, so we can access it
   ## from "outside" the session instance later (see below)
   ##
   session_factory._myAppSession = None


   ## create a WAMP-over-WebSocket transport client factory
   ##
   from autobahn.twisted.websocket import WampWebSocketClientFactory
   transport_factory = WampWebSocketClientFactory(session_factory, "ws://127.0.0.1:8080/ws")


   ## start a WebSocket client from an endpoint
   ##
   client = clientFromString(reactor, "tcp:127.0.0.1:8080")
   client.connect(transport_factory)


   ## publish an event every second from the (single) application session