def run(entry_points):

    transports = [
        {
            "type": "websocket",
            "url": "ws://127.0.0.1:8080/ws"
        }
    ]

    done = []

    for main in entry_points:
        connection = Connection(main, realm=u'public',
            transports=transports, reactor=reactor)
        done.append(connection.connect())

    # deferred that fires when all connections are done
    done = txaio.gather(done)

    def finish(res):
        print("all connections done", res)
        reactor.stop()

    done.addBoth(finish)

    reactor.run()
Esempio n. 2
0
def run(on_create):
    """
    This could be a high level "runner" tool we ship.
    """
    from twisted.internet import reactor

    # multiple, configurable transports, either via dict-like config, or
    # from native Twisted endpoints
    transports = [
        {
            "type": "websocket",
            "url": "ws://127.0.0.1:8080/ws"
        }
    ]

    # a connection connects and automatically reconnects WAMP client
    # transports to a WAMP router. A connection has a listener system
    # where user code can hook into different events : on_join
    connection = Connection(on_create, realm=u'public',
        transports=transports, reactor=reactor)

    # the following returns a deferred that fires when the connection is
    # finally done: either by explicit close by user code, or by error or
    # when stop reconnecting
    done = connection.connect()

    def finish(res):
        print(res)
        reactor.stop()

    done.addBoth(finish)

    reactor.run()
Esempio n. 3
0
def run(on_create):
    """
    This could be a high level "runner" tool we ship.
    """
    from twisted.internet import reactor

    # multiple, configurable transports, either via dict-like config, or
    # from native Twisted endpoints
    transports = [{"type": "websocket", "url": "ws://127.0.0.1:8080/ws"}]

    # a connection connects and automatically reconnects WAMP client
    # transports to a WAMP router. A connection has a listener system
    # where user code can hook into different events : on_join
    connection = Connection(on_create,
                            realm='public',
                            transports=transports,
                            reactor=reactor)

    # the following returns a deferred that fires when the connection is
    # finally done: either by explicit close by user code, or by error or
    # when stop reconnecting
    done = connection.connect()

    def finish(res):
        print(res)
        reactor.stop()

    done.addBoth(finish)

    reactor.run()
def run(entry_points):

    transports = [{"type": "websocket", "url": "ws://127.0.0.1:8080/ws"}]

    done = []

    for main in entry_points:
        connection = Connection(main,
                                realm=u'public',
                                transports=transports,
                                reactor=reactor)
        done.append(connection.connect())

    # deferred that fires when all connections are done
    done = txaio.gather(done)

    def finish(res):
        print("all connections done", res)
        reactor.stop()

    done.addBoth(finish)

    reactor.run()