2019-04-02 09:07:07 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from time import sleep
|
|
|
|
|
2019-04-04 07:57:49 +00:00
|
|
|
from vnpy.rpc import RpcClient
|
2019-04-02 09:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestClient(RpcClient):
|
|
|
|
"""
|
|
|
|
Test RpcClient
|
2019-04-04 07:57:49 +00:00
|
|
|
"""
|
|
|
|
|
2019-04-02 09:07:07 +00:00
|
|
|
def __init__(self, req_address, sub_address):
|
|
|
|
"""
|
|
|
|
Constructor
|
|
|
|
"""
|
|
|
|
super(TestClient, self).__init__(req_address, sub_address)
|
|
|
|
|
|
|
|
def callback(self, topic, data):
|
|
|
|
"""
|
|
|
|
Realize callable function
|
|
|
|
"""
|
2019-07-01 13:35:28 +00:00
|
|
|
print(f"client received topic:{topic}, data:{data}")
|
2019-04-02 09:07:07 +00:00
|
|
|
|
|
|
|
|
2019-07-01 13:35:28 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
req_address = "tcp://localhost:2014"
|
2019-07-02 01:32:46 +00:00
|
|
|
sub_address = "tcp://localhost:4102"
|
2019-04-02 09:07:07 +00:00
|
|
|
|
|
|
|
tc = TestClient(req_address, sub_address)
|
2019-07-01 13:35:28 +00:00
|
|
|
tc.subscribe_topic("")
|
2019-04-02 09:07:07 +00:00
|
|
|
tc.start()
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
print(tc.add(1, 3))
|
|
|
|
sleep(2)
|