Beispiel #1
0
    def run(self, arg):
        print "Service base test:"
        # Create service: my_svc
        svc = Service("svcbase_test_svc")
        svc.codec = Service.CODEC_BINARY
        svc.start()

        # Listen
        ip = "127.0.0.1"
        port = 7788
        listen_sid = svc.listen(ip, port)
        print "Service {} listening in {}:{}, session Id: {}".format(svc.name, ip, port, listen_sid)

        # Connect to listen session.
        conn_sid = svc.connect(ip, port)
        print "Connect to {}:{} success, sid: {}".format(ip, port, conn_sid)

        # Send data.
        svc.send(conn_sid, TestData())
        # Test unhandled packet.
        svc.send(conn_sid, data=3, opcode=10086, status=0)

        # Create service: another_svc
        another = Service("another")
        another.codec = Service.CODEC_BINARY
        another.start()

        # Schedule.
        Service.schedule()

        # If deschedule, will gone to here.
        # Delete my_svc service.
        del Service.my_svc
        del Service.another
Beispiel #2
0
    def run(self, arg):
        print 'Service base test:'
        # Create service: my_svc
        svc = Service('svcbase_test_svc')
        svc.codec = Service.CODEC_BINARY
        svc.start()

        # Listen
        ip = '127.0.0.1'
        port = 7788
        listen_sid = svc.listen(ip, port)
        print 'Service {} listening in {}:{}, session Id: {}'.format(svc.name, ip, port, listen_sid)

        # Connect to listen session.
        conn_sid = svc.connect(ip, port)
        print 'Connect to {}:{} success, sid: {}'.format(ip, port, conn_sid)

        # Send data.
        svc.send(conn_sid, TestData())
        # Test unhandled packet.
        svc.send(conn_sid, data=3, opcode=10086, status=0)

        # Create service: another_svc
        another = Service('another')
        another.codec = Service.CODEC_BINARY
        another.start()

        # Schedule.
        Service.schedule()

        # If deschedule, will gone to here.
        # Delete my_svc service.
        del Service.svcbase_test_svc
        del Service.another