[Add]增加SocketIO测试脚本

This commit is contained in:
vn.py 2018-01-21 19:06:47 +08:00
parent 20bb34c045
commit d88245db6e
3 changed files with 48 additions and 3 deletions

View File

@ -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)
app.run(debug=True)
#socketio.run(app)

View File

@ -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)

View File

@ -5,4 +5,6 @@ qdarkstyle
SortedContainers
futuquant
wmi
future
future
flask-socketio
flask-restful