vnpy/examples/WebTrader/test.py

63 lines
1.6 KiB
Python
Raw Normal View History

2018-01-21 11:06:47 +00:00
# encoding: UTF-8
2018-01-22 09:34:49 +00:00
from socketIO_client import SocketIO, BaseNamespace
2018-01-21 11:06:47 +00:00
from time import sleep
from threading import Thread
2018-01-22 09:34:49 +00:00
import logging
2018-01-21 11:06:47 +00:00
#----------------------------------------------------------------------
def on_connect():
"""连接"""
print 'on connect'
#----------------------------------------------------------------------
def on_disconnect():
"""断开"""
print 'disconnect'
#----------------------------------------------------------------------
def on_reconnect():
"""重连"""
print 'reconnect'
#----------------------------------------------------------------------
def on_test(*args):
"""测试"""
print 'on_test', args
2018-01-22 09:34:49 +00:00
########################################################################
class TestNamespace(BaseNamespace):
""""""
#----------------------------------------------------------------------
def on_connect(self):
"""连接"""
print 'on connect'
#----------------------------------------------------------------------
def on_disconnect(self):
"""断开"""
print 'disconnect'
#----------------------------------------------------------------------
def on_reconnect(self):
"""重连"""
print 'reconnect'
2018-01-21 11:06:47 +00:00
2018-01-22 09:34:49 +00:00
#----------------------------------------------------------------------
def on_message(self, *args):
"""测试"""
print 'on_message', args
2018-01-21 11:06:47 +00:00
2018-01-22 09:34:49 +00:00
if __name__ == '__main__':
#logging.getLogger('socketIO-client').setLevel(logging.DEBUG)
#logging.basicConfig()
sio = SocketIO('127.0.0.1', 5000, TestNamespace, transports='websocket')
sio.wait()