Type/to search
0
Follow
0
Followers
OKEx 웹소켓을 요청하려면 어떻게 해야 하나요?
Help
Created 2021-07-05 14:18:21  
 1
 1542

img
function main(){
var param = {
"op": "subscribe",
"args": [
{
"channel" : "instruments",
"instType": "FUTURES"
}
]
}
// Dial 함수를 호출할 때reconnect=true다시 연결 모드로 설정하고,payload다시 연결할 때 전송되는 메시지죠. 웹소켓 연결이 끊어지면 자동으로 다시 연결되고, 자동으로 메시지를 전송합니다.
var ws = Dial("wss://wsaws.okex.com:8443/ws/v5/public|compress=gzip_raw&mode=recv&reconnect=true&"+ JSON.stringify(param))
if(ws){
ws.write(JSON.stringify(param))
var pingCyc = 1000 * 20
var lastPingTime = new Date().getTime()
while(1){
var nowTime = new Date().getTime()
var ret = ws.read()
Log("ret:", ret)
if(nowTime - lastPingTime > pingCyc){
var retPing = ws.write("ping")
lastPingTime = nowTime
로그 (log): "파견:ping", "#FF0000")
}
LogStatus (현재 시간: 11시)_D())
Sleep(1000)
}
ws.close()
}
}

예를 들어, 위의 코드가 okex의 websocket 인터페이스의 제품 채널을 요청하는 경우, 항상 시간이 지남에 따라, 누가 올바른 코드를 줄 수 있습니까?

Related Recommendations
Comment
All comments (1)

    需要海外托管者,另外不要使用调试工具调试wss

    5 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)