示例#1
0
    def __init__(self, config):
        super(Client, self).__init__()
        self.config = config

        self.events = Emitter()
        self.packets = Emitter()

        self.api = APIClient(self.config.token, self)
        self.gw = GatewayClient(self, self.config.max_reconnects,
                                self.config.encoder)
        self.state = State(self, StateConfig(self.config.get('state', {})))

        if self.config.manhole_enable:
            self.manhole_locals = {
                'client': self,
                'state': self.state,
                'api': self.api,
                'gw': self.gw,
            }

            self.manhole = DiscoBackdoorServer(
                self.config.manhole_bind,
                banner='Disco Manhole',
                localf=lambda: self.manhole_locals)
            self.manhole.start()
示例#2
0
def get_state(config=None):
    return State(MockClient(), config or StateConfig())