def __init__(self, server_url, roomId): self._client = ddp.ConcurrentDDPClient(server_url) self._roomId = roomId handlers = { tuple(xrange(41, 52 + 1)): self._disable_all_players, (57, ): self._show_message, (59, ): self._hide_message, (64, ): self._enable_single_player, (74, ): self._enable_all_players, } self._handlers = {} for notes, handler in handlers.iteritems(): for note in notes: self._handlers[note] = handler
def main(argv=None): args = parse_argv(argv) config_logging(args) print('\n'.join(map(str.strip, r''' +-----+---------------+ | Key | Drum | +-----+---------------+ | a | Hi-hat stamp | | c | Crash cymbal | | h | Hi-hat closed | | k | Kick | | o | Hi-hat open | | p | Hi-hat pedal | | r | Ride cymbal | | s | Snare | | t | High tom | | u | Low tom | | y | Mid tom | +-----+---------------+ Press 'q' to quit '''.split('\n')))) client = ddp.ConcurrentDDPClient(args.server_url) fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) try: client.start() tty.setraw(fd) fake_drums(client, args.room_id) finally: try: termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) except: pass try: client.stop() client.join() except: pass return 0
def __init__(self, server_url, roomId): self._client = ddp.ConcurrentDDPClient(server_url) self._roomId = roomId
#!/usr/bin/env python import logging logging.basicConfig() import ddp client = ddp.ConcurrentDDPClient('ws://127.0.0.1:3000/websocket', debug=False) client.start() future = client.call('upper', 'Hello, World!') result_message = future.get() if result_message.has_result(): print 'Result:', result_message.result if result_message.has_error(): print 'Error:', result_message.error client.stop() client.join()
# Import the DDP package. import ddp # Create a client, passing the URL of the server. client = ddp.ConcurrentDDPClient('ws://127.0.0.1:3000/websocket') # Once started, the client will maintain a connection to the server. client.start() # The method is executed asynchronously. future = client.call('upper', 'Hello, World!') # ... Do something else ... # Block until the result message is received. result_message = future.get() # Check if an error occured else print the result. if result_message.has_error(): print result_message.error else: print result_message.result # Ask the client to stop and wait for it to do so. client.stop() client.join()