Ejemplo n.º 1
0
 def __init__(self, tid, username, auth_key):
     LTTwistedClient.__init__(self, TI_PROTOCOL, self.msg_received, self.got_connected, self.got_disconnected, False)
     self.conn = None
     self.tid = tid
     self.username = username
     self.auth_key = auth_key
     self.prev_bn_msg = None
     self.tap_trackers = {} # key=(node,intf) => maps to TapTracker
Ejemplo n.º 2
0
 def __init__(self, tid, username, auth_key):
     LTTwistedClient.__init__(self, TI_PROTOCOL, self.msg_received,
                              self.got_connected, self.got_disconnected,
                              False)
     self.conn = None
     self.tid = tid
     self.username = username
     self.auth_key = auth_key
     self.prev_bn_msg = None
     self.tap_trackers = {}  # key=(node,intf) => maps to TapTracker
Ejemplo n.º 3
0
    if len(sys.argv) < 2:
        print >> sys.stderr, "usage: ./test_ltprotocol.py TYPE"
        sys.exit(-1)

    what = sys.argv[1]
    if what != "client" and what != "server":
        print >> sys.stderr, "TYPE must be client or server"
        sys.exit(-1)

    # periodically sends some messages
    def periodic_send(proto):
        if proto.connected:
            print 'sending ...'
            proto.send(NumMsg(200))
            proto.send(StrMsg("hello world!"))
            proto.send(NumMsg(7))
            reactor.callLater(1, lambda : periodic_send(proto))

    if what == "client":
        client = LTTwistedClient(TEST_PROTOCOL,
                                 lambda p, m : print_ltm('client', p, m))
        client.connect('127.0.0.1', 9999)
    else:
        server = LTTwistedServer(TEST_PROTOCOL,
                                 lambda p, m : print_ltm('server', p, m),
                                 periodic_send,
                                 print_disconnect)
        server.listen(9999)

    reactor.run()