def main(): options = yield getStepperMotorOptions() url = yield getStepperMotorURL(options) StepperMotorClient.__ccname__ = '(%s) sm client' % options['name'] protocol = yield getProtocol(url) smc = StepperMotorClient(protocol) runConsoleClient( StepperMotorConsoleClient, smc )
self.counter = 0 self.protocol = yield getProtocol(MESSAGE_SERVER) @consoleCommand("subscribe") def subscribeToMessage(self): return self.protocol.messageSubscribe("counter-updated", self.onCounterUpdated) @consoleCommand("unsubscribe") def unsubscribeFromMessage(self): return self.protocol.messageUnsubscribe("counter-updated") def onCounterUpdated(self, data): self.counter += 1 @consoleCommand("start", "starts message timer") def startTimer(self): return self.protocol.sendCommand("start-timer") @consoleCommand("stop", "stops message timer") def stopTimer(self): return self.protocol.sendCommand("stop-timer") @consoleCommand("get count", "retrieve number of messages received") def getCount(self): return self.counter if __name__ == "__main__": runConsoleClient(MessageClient) reactor.run()
self.protocol = yield getProtocol(MESSAGE_SERVER) @consoleCommand('subscribe') def subscribeToMessage(self): return self.protocol.messageSubscribe('counter-updated', self.onCounterUpdated) @consoleCommand('unsubscribe') def unsubscribeFromMessage(self): return self.protocol.messageUnsubscribe('counter-updated') def onCounterUpdated(self, data): self.counter += 1 @consoleCommand('start', 'starts message timer') def startTimer(self): return self.protocol.sendCommand('start-timer') @consoleCommand('stop', 'stops message timer') def stopTimer(self): return self.protocol.sendCommand('stop-timer') @consoleCommand('get count', 'retrieve number of messages received') def getCount(self): return self.counter if __name__ == '__main__': runConsoleClient(MessageClient) reactor.run()