Commit ff57d4f6 authored by Chunchi Che's avatar Chunchi Che

update stream.ts

parent bb640b14
Pipeline #22111 passed with stages
in 16 minutes and 4 seconds
...@@ -11,71 +11,12 @@ ...@@ -11,71 +11,12 @@
"cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb", "cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb",
"stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf", "stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"chainALL": false, "chainALL": false,
"streamInterval": 200,
"ui":{ "ui":{
"ground":{
"width":9.9,
"height":8
},
"card":{
"transform":{
"x":0.8,
"y":1,
"z":0.05
},
"rotation":{
"x":1.55,
"y":0,
"z":0
},
"reverseRotation":{
"x":1.55,
"y":3.1,
"z":0
},
"defenceRotation":{
"x":1.55,
"y":1.55,
"z":0
},
"handRotation":{
"x":1,
"y":0,
"z":0
},
"handHoverScaling":{
"x":1.2,
"y":1.2,
"z":1
},
"floating":0.02
},
"layout":{
"header":{
"height":80
},
"content":{
"height":800
},
"sider":{
"width":300
},
"footer":{
"height":80
}
},
"status":{
"avatarSize":40,
"meAvatarColor":"#0e63e1",
"opAvatarColor":"#e10e68"
},
"hint":{ "hint":{
"waitingDuration":1.5, "waitingDuration":1.5,
"maxCount": 1 "maxCount": 1
}, }
"commonDelay": 200,
"moveDelay": 500,
"chainingDelay": 800,
"attackDelay": 500
}, },
"unimplementedWhiteList":[ "unimplementedWhiteList":[
1, 1,
......
...@@ -11,71 +11,12 @@ ...@@ -11,71 +11,12 @@
"cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb", "cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb",
"stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf", "stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"chainALL": false, "chainALL": false,
"streamInterval": 200,
"ui":{ "ui":{
"ground":{
"width":9.9,
"height":8
},
"card":{
"transform":{
"x":0.8,
"y":1,
"z":0.05
},
"rotation":{
"x":1.55,
"y":0,
"z":0
},
"reverseRotation":{
"x":1.55,
"y":3.1,
"z":0
},
"defenceRotation":{
"x":1.55,
"y":1.55,
"z":0
},
"handRotation":{
"x":1,
"y":0,
"z":0
},
"handHoverScaling":{
"x":1.2,
"y":1.2,
"z":1
},
"floating":0.02
},
"layout":{
"header":{
"height":80
},
"content":{
"height":800
},
"sider":{
"width":300
},
"footer":{
"height":80
}
},
"status":{
"avatarSize":40,
"meAvatarColor":"#0e63e1",
"opAvatarColor":"#e10e68"
},
"hint":{ "hint":{
"waitingDuration":1.5, "waitingDuration":1.5,
"maxCount": 1 "maxCount": 1
}, }
"commonDelay": 200,
"moveDelay": 500,
"chainingDelay": 800,
"attackDelay": 500
}, },
"unimplementedWhiteList":[ "unimplementedWhiteList":[
1, 1,
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
// 现在我们有这样一个需求:需要保证每次只处理一个消息,在上一个消息处理完后,再进行下一个消息的处理。 // 现在我们有这样一个需求:需要保证每次只处理一个消息,在上一个消息处理完后,再进行下一个消息的处理。
// //
// 因此封装了一个`WebSocketStream`类,当每次Websocket连接中有消息到达时,往流中添加event, // 因此封装了一个`WebSocketStream`类,当每次Websocket连接中有消息到达时,往流中添加event,
import { useConfig } from "@/config";
import { sleep } from "./sleep";
// 同时执行器会不断地从流中获取event进行处理。 // 同时执行器会不断地从流中获取event进行处理。
export class WebSocketStream { export class WebSocketStream {
public ws: WebSocket; public ws: WebSocket;
...@@ -48,7 +53,10 @@ export class WebSocketStream { ...@@ -48,7 +53,10 @@ export class WebSocketStream {
return; return;
} else { } else {
// websocket not closed, handle next message from server // websocket not closed, wait some time, and then handle next message from server
await sleep(useConfig().streamInterval);
return reader.read().then(process); return reader.read().then(process);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment