def handle(self):
     print 'Connection accepted from {}:{}'.format(*self.client_address)
     stream = framing.Stream(self.rfile, self.wfile)
     dispatcher = Dispatcher(Handler())
     logger = lambda data, direction=None: sys.stdout.write(
             '{} {}\n'.format('<--' if direction == 'in' else '-->', data))
     util.dispatch_loop(stream, dispatcher, json, logger)
Example #2
0
def handle(sock, address):
    print 'Connection accepted from {}:{}'.format(*address)
    rfile, wfile = sock.makefile('rb', -1), sock.makefile('wb', 0)
    stream = framing.Stream(rfile, wfile)
    dispatcher = Dispatcher(Handler())
    logger = lambda data, direction=None: sys.stdout.write(
            '{} {}\n'.format('<--' if direction == 'in' else '-->', data))
    util.dispatch_loop(stream, dispatcher, json, logger)