def run(self, arg): print('Event test:') # Create service: event_test_svc svc = Service('event_test_svc') svc.codec = Service.CODEC_BINARY svc.start() svc.fps = 1 Service.schedule()
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) # Set service fps. svc.fps = 200 # Send data. for i in range( 50 ): # Note: You can modify range limit to execute performance test. 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