Beispiel #1
0
def start_server(config):
    log.startLogging(sys.stdout)
    router_factory = wamp.RouterFactory()
    session_factory = wamp.RouterSessionFactory(router_factory)
    component_config = types.ComponentConfig(realm=config['realm'])
    component_session = MindwaveComponent(component_config)
    component_session.app_config = config
    session_factory.add(component_session)
    transport_factory = websocket.WampWebSocketServerFactory(session_factory,
                                                             debug=False,
                                                             debug_wamp=False)
    server = serverFromString(reactor, config['server_string'])
    server.listen(transport_factory)
    reactor.run()
Beispiel #2
0
def get_wamp_service(config):
    debug = config.get("websocket", "debug") == "true"
    client.load_config(config)

    router_factory = wamp.RouterFactory()
    session_factory = wamp.RouterSessionFactory(router_factory)
    component_config = types.ComponentConfig(realm="anonymous")
    session_factory.add(client.DocumentSession(component_config))

    transport_factory = websocket.WampWebSocketServerFactory(session_factory,
                                                             debug=debug,
                                                             debug_wamp=debug)

    server = internet.TCPServer(int(config.get("websocket", "port")),
                                transport_factory,
                                interface=config.get("websocket", "interface"))

    return server
    def onJoin(self, details):
        # regs = []
        yield self.register(rpc_bdata, u'ru.bustime.rpc_bdata')
        yield self.register(rpc_passenger, u'ru.bustime.rpc_passenger')
        # mobile support only
        yield self.register(rpc_bootstrap_amounts,
                            u'ru.bustime.rpc_bootstrap_amounts')
        yield self.register(rpc_tcard, u'ru.bustime.rpc_tcard')
        yield self.register(rpc_stop_ids, u'ru.bustime.rpc_stop_ids')


def accept(offers):
    for offer in offers:
        if isinstance(offer, PerMessageDeflateOffer):
            return PerMessageDeflateOfferAccept(offer)


if __name__ == '__main__':
    router_factory = wamp.RouterFactory()
    session_factory = wamp.RouterSessionFactory(router_factory)
    component_config = types.ComponentConfig(realm="realm1")
    component_session = MyBackendComponent(component_config)
    session_factory.add(component_session)

    transport_factory = websocket.WampWebSocketServerFactory(session_factory,
                                                             debug=False,
                                                             debug_wamp=False)
    server = serverFromString(reactor, "tcp:%s" % PORT)
    server.listen(transport_factory)
    reactor.run()