diff --git a/examples/WebTrader/run.py b/examples/WebTrader/run.py index af23aa4a..0a7152f3 100644 --- a/examples/WebTrader/run.py +++ b/examples/WebTrader/run.py @@ -253,7 +253,10 @@ def handleEvent(event): """处理事件""" eventType = event.type_ eventData = event.dict_['data'].__dict__ - socketio.emit(eventType, eventData, broadcast=True) + #socketio.emit(eventType, eventData, broadcast=True) + socketio.emit('test', eventData, broadcast=True) + + print eventData ee.register(EVENT_TICK, handleEvent) @@ -269,4 +272,5 @@ ee.register(EVENT_ERROR, handleEvent) if __name__ == '__main__': - app.run(debug=True) \ No newline at end of file + app.run(debug=True) + #socketio.run(app) \ No newline at end of file diff --git a/examples/WebTrader/test.py b/examples/WebTrader/test.py new file mode 100644 index 00000000..c5be3e68 --- /dev/null +++ b/examples/WebTrader/test.py @@ -0,0 +1,39 @@ +# encoding: UTF-8 + +from socketIO_client import SocketIO, LoggingNamespace +from time import sleep +from threading import Thread + +#---------------------------------------------------------------------- +def on_connect(): + """连接""" + print 'on connect' + +#---------------------------------------------------------------------- +def on_disconnect(): + """断开""" + print 'disconnect' + +#---------------------------------------------------------------------- +def on_reconnect(): + """重连""" + print 'reconnect' + +#---------------------------------------------------------------------- +def on_test(*args): + """测试""" + print 'on_test', args + + +if __name__ == '__main__': + sio = SocketIO('127.0.0.1', 5000, LoggingNamespace) + sio.on('connect', on_connect) + sio.on('disconnect', on_disconnect) + sio.on('reconnect', on_reconnect) + sio.on('test', on_test) + + t = Thread(target=sio.wait) + t.start() + + while True: + sleep(1) diff --git a/requirements.txt b/requirements.txt index 180feca0..530b5a60 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,6 @@ qdarkstyle SortedContainers futuquant wmi -future \ No newline at end of file +future +flask-socketio +flask-restful \ No newline at end of file