Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
deft
Neos
Commits
fab74f46
Commit
fab74f46
authored
May 19, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unused delay in onSocketMessage.ts
parent
e47d0dd2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
33 deletions
+0
-33
src/service/onSocketMessage.ts
src/service/onSocketMessage.ts
+0
-33
No files found.
src/service/onSocketMessage.ts
View file @
fab74f46
...
...
@@ -2,12 +2,8 @@
* 长连接消息事件订阅处理逻辑
*
* */
import
{
ygopro
}
from
"
@/api
"
;
import
{
adaptStoc
}
from
"
@/api/ocgcore/ocgAdapter/adapter
"
;
import
{
YgoProPacket
}
from
"
@/api/ocgcore/ocgAdapter/packet
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
matStore
}
from
"
@/stores
"
;
import
handleGameMsg
from
"
./duel/gameMsg
"
;
import
handleTimeLimit
from
"
./duel/timeLimit
"
;
...
...
@@ -22,8 +18,6 @@ import handleHsWatchChange from "./room/hsWatchChange";
import
handleJoinGame
from
"
./room/joinGame
"
;
import
handleTypeChange
from
"
./room/typeChange
"
;
const
NeosConfig
=
useConfig
();
/*
* 先将从长连接中读取到的二进制数据通过Adapter转成protobuf结构体,
* 然后再分发到各个处理函数中去处理。
...
...
@@ -32,9 +26,6 @@ const NeosConfig = useConfig();
export
default
async
function
handleSocketMessage
(
e
:
MessageEvent
)
{
const
packet
=
YgoProPacket
.
deserialize
(
e
.
data
);
const
pb
=
adaptStoc
(
packet
);
const
delay
=
handleDelay
(
pb
);
await
sleep
(
delay
);
switch
(
pb
.
msg
)
{
case
"
stoc_join_game
"
:
{
...
...
@@ -110,27 +101,3 @@ export default async function handleSocketMessage(e: MessageEvent) {
}
}
}
// 该函数用于控频,防止MSG更新太频繁,返回值是延迟的时间戳(毫秒)
//
// 对于一般的MSG,我们会延迟200ms执行处理逻辑;
// 当处理一些带有动画效果的MSG时,比如`MSG_MOVE`,`MSG_CHAINING`,我们会设置下一次执行处理逻辑的延迟,确保动画完整
function
handleDelay
(
stoc
:
ygopro
.
YgoStocMsg
):
number
{
const
delay
=
matStore
.
delay
;
// 重置下次`delay`
matStore
.
delay
=
NeosConfig
.
ui
.
commonDelay
;
// 对特定的`MSG`,设置特化的`delay`
if
(
stoc
.
has_stoc_game_msg
)
{
if
(
stoc
.
stoc_game_msg
.
gameMsg
==
"
move
"
)
{
matStore
.
delay
=
NeosConfig
.
ui
.
moveDelay
+
500
;
}
else
if
(
stoc
.
stoc_game_msg
.
gameMsg
==
"
chaining
"
)
{
matStore
.
delay
=
NeosConfig
.
ui
.
chainingDelay
;
}
else
if
(
stoc
.
stoc_game_msg
.
gameMsg
==
"
attack
"
)
{
matStore
.
delay
=
NeosConfig
.
ui
.
attackDelay
+
200
;
}
}
return
delay
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment