更新,兼容websocket不同版本
This commit is contained in:
parent
252f54b366
commit
6c1bb74966
@ -141,23 +141,25 @@ class OkexApi(object):
|
|||||||
self.thread.join()
|
self.thread.join()
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onMessage(self, ws, evt):
|
def onMessage(self, *args):
|
||||||
"""
|
"""
|
||||||
信息推送事件
|
信息推送事件
|
||||||
:param ws: 接口
|
:param ws: 接口
|
||||||
:param evt: 事件
|
:param evt: 事件
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
evt = args[-1]
|
||||||
print(u'vnokex.onMessage:{}'.format(evt))
|
print(u'vnokex.onMessage:{}'.format(evt))
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onError(self, ws, evt):
|
def onError(self, *args):
|
||||||
"""
|
"""
|
||||||
接口错误推送事件
|
接口错误推送事件
|
||||||
:param ws:
|
:param ws:
|
||||||
:param evt:
|
:param evt:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
evt = args[-1]
|
||||||
print(u'vnokex.onApiError:{}'.format(evt))
|
print(u'vnokex.onApiError:{}'.format(evt))
|
||||||
|
|
||||||
|
|
||||||
|
@ -430,17 +430,21 @@ class OkexSpotApi(WsSpotApi):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onMessage(self, ws, evt):
|
def onMessage(self, *args):
|
||||||
"""
|
"""
|
||||||
响应信息处理,包括心跳响应、请求响应、数据推送
|
响应信息处理,包括心跳响应、请求响应、数据推送
|
||||||
:param ws: websocket接口
|
:param ws: websocket接口
|
||||||
:param evt: 消息体
|
:param evt: 消息体
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
# str => json
|
evt = args[-1]
|
||||||
decmp_evt = self.inflate(evt)
|
if isinstance(evt,bytes):
|
||||||
ws_data = self.readData(decmp_evt)
|
# bytes = > str => json
|
||||||
|
decmp_evt = self.inflate(evt)
|
||||||
|
ws_data = self.readData(decmp_evt)
|
||||||
|
else:
|
||||||
|
# str => json
|
||||||
|
ws_data = self.readData(evt)
|
||||||
if self.gateway.log_message:
|
if self.gateway.log_message:
|
||||||
self.gateway.writeLog(u'SpotApi.onMessage:{}'.format(ws_data))
|
self.gateway.writeLog(u'SpotApi.onMessage:{}'.format(ws_data))
|
||||||
|
|
||||||
@ -495,8 +499,12 @@ class OkexSpotApi(WsSpotApi):
|
|||||||
self.gateway.writeError(u'Spot unkown msg:{}'.format(data))
|
self.gateway.writeError(u'Spot unkown msg:{}'.format(data))
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onError(self, ws, evt):
|
def onError(self, *args):
|
||||||
"""Api方法重载,错误推送"""
|
"""Api方法重载,错误推送"""
|
||||||
|
evt = None
|
||||||
|
if len(args) == 2:
|
||||||
|
evt = args[-1]
|
||||||
|
|
||||||
error = VtErrorData()
|
error = VtErrorData()
|
||||||
error.gatewayName = self.gatewayName
|
error.gatewayName = self.gatewayName
|
||||||
error.errorID = 0
|
error.errorID = 0
|
||||||
@ -1565,17 +1573,21 @@ class OkexFuturesApi(WsFuturesApi):
|
|||||||
self._use_leverage = __leverage
|
self._use_leverage = __leverage
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onMessage(self, ws, evt):
|
def onMessage(self, *args):
|
||||||
"""
|
"""
|
||||||
信息推送的处理
|
信息推送的处理
|
||||||
:param ws:
|
:param ws:
|
||||||
:param evt:
|
:param evt:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
# str => json
|
evt = args[-1]
|
||||||
decmp_evt = self.inflate(evt)
|
if isinstance(evt,bytes):
|
||||||
ws_data = self.readData(decmp_evt)
|
# bytes => str => json
|
||||||
#ws_data = self.readData(evt)
|
decmp_evt = self.inflate(evt)
|
||||||
|
ws_data = self.readData(decmp_evt)
|
||||||
|
else:
|
||||||
|
# str => json
|
||||||
|
ws_data = self.readData(evt)
|
||||||
|
|
||||||
if self.gateway.log_message:
|
if self.gateway.log_message:
|
||||||
self.gateway.writeLog(u'FutureApi.onMessage:{}'.format(ws_data))
|
self.gateway.writeLog(u'FutureApi.onMessage:{}'.format(ws_data))
|
||||||
@ -1639,8 +1651,9 @@ class OkexFuturesApi(WsFuturesApi):
|
|||||||
self.writeLog(u'unkonw msg:{}'.format(data))
|
self.writeLog(u'unkonw msg:{}'.format(data))
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onError(self, ws, evt):
|
def onError(self,*args):
|
||||||
"""重载WsFutureApi.onError错误Event推送"""
|
"""重载WsFutureApi.onError错误Event推送"""
|
||||||
|
evt = args[-1]
|
||||||
error = VtErrorData()
|
error = VtErrorData()
|
||||||
error.gatewayName = self.gatewayName
|
error.gatewayName = self.gatewayName
|
||||||
if isinstance(evt,bytes):
|
if isinstance(evt,bytes):
|
||||||
|
Loading…
Reference in New Issue
Block a user