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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
MyCard
Neos
Commits
9b55b152
Commit
9b55b152
authored
Jul 10, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update replay
parent
2439957d
Pipeline
#22613
failed with stages
in 1 minute and 39 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
src/middleware/socket.ts
src/middleware/socket.ts
+10
-6
src/ui/Replay/index.tsx
src/ui/Replay/index.tsx
+14
-2
No files found.
src/middleware/socket.ts
View file @
9b55b152
...
@@ -27,7 +27,10 @@ export interface socketAction {
...
@@ -27,7 +27,10 @@ export interface socketAction {
passWd
:
string
;
passWd
:
string
;
};
};
isReplay
?:
boolean
;
// 是否是回放模式
isReplay
?:
boolean
;
// 是否是回放模式
replayUrl
?:
string
;
// 提供回放服务的地址,当`isReplay`为true时,必传
replayInfo
?:
{
Url
:
string
;
// 提供回放服务的地址
data
:
ArrayBuffer
;
// 回放数据
};
// 通过长连接发送的数据
// 通过长连接发送的数据
payload
?:
Uint8Array
;
payload
?:
Uint8Array
;
}
}
...
@@ -38,17 +41,18 @@ let ws: WebSocketStream | null = null;
...
@@ -38,17 +41,18 @@ let ws: WebSocketStream | null = null;
export
default
async
function
(
action
:
socketAction
)
{
export
default
async
function
(
action
:
socketAction
)
{
switch
(
action
.
cmd
)
{
switch
(
action
.
cmd
)
{
case
socketCmd
.
CONNECT
:
{
case
socketCmd
.
CONNECT
:
{
const
{
initInfo
:
info
,
isReplay
,
replay
Url
}
=
action
;
const
{
initInfo
:
info
,
isReplay
,
replay
Info
}
=
action
;
if
(
info
)
{
if
(
info
)
{
ws
=
new
WebSocketStream
(
info
.
ip
,
(
conn
,
_event
)
=>
ws
=
new
WebSocketStream
(
info
.
ip
,
(
conn
,
_event
)
=>
handleSocketOpen
(
conn
,
info
.
ip
,
info
.
player
,
info
.
passWd
)
handleSocketOpen
(
conn
,
info
.
ip
,
info
.
player
,
info
.
passWd
)
);
);
await
ws
.
execute
(
handleSocketMessage
);
await
ws
.
execute
(
handleSocketMessage
);
}
else
if
(
isReplay
&&
replayUrl
)
{
}
else
if
(
isReplay
&&
replayInfo
)
{
ws
=
new
WebSocketStream
(
replayUrl
,
()
=>
ws
=
new
WebSocketStream
(
replayInfo
.
Url
,
(
conn
,
_event
)
=>
{
console
.
info
(
"
replay websocket open.
"
)
console
.
info
(
"
replay websocket open.
"
);
);
conn
.
send
(
replayInfo
.
data
);
});
await
ws
.
execute
(
handleSocketMessage
);
await
ws
.
execute
(
handleSocketMessage
);
}
}
...
...
src/ui/Replay/index.tsx
View file @
9b55b152
...
@@ -5,6 +5,8 @@ import { Button, message, Modal, Upload, UploadProps } from "antd";
...
@@ -5,6 +5,8 @@ import { Button, message, Modal, Upload, UploadProps } from "antd";
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
@/middleware/socket
"
;
const
ReplayModal
:
React
.
FC
=
()
=>
{
const
ReplayModal
:
React
.
FC
=
()
=>
{
const
[
replay
,
setReplay
]
=
useState
<
null
|
ArrayBuffer
>
(
null
);
const
[
replay
,
setReplay
]
=
useState
<
null
|
ArrayBuffer
>
(
null
);
const
uploadProps
:
UploadProps
=
{
const
uploadProps
:
UploadProps
=
{
...
@@ -31,13 +33,23 @@ const ReplayModal: React.FC = () => {
...
@@ -31,13 +33,23 @@ const ReplayModal: React.FC = () => {
if
(
replay
===
null
)
{
if
(
replay
===
null
)
{
message
.
error
(
"
请先上传录像文件
"
);
message
.
error
(
"
请先上传录像文件
"
);
}
else
{
}
else
{
// 连接回放websocket服务
socketMiddleWare
({
cmd
:
socketCmd
.
CONNECT
,
isReplay
:
true
,
replayInfo
:
{
Url
:
"
replay.neos.moe
"
,
// TODO: useConfig
data
:
replay
,
},
});
// 跳转
// 跳转
// TODO
navigate
(
"
/duel/neos/replay/replay.neos.moe
"
);
}
}
}
}
}
}
onCancel=
{
()
=>
{
onCancel=
{
()
=>
{
// 断开websocket连接
// 断开websocket连接
// TODO
socketMiddleWare
({
cmd
:
socketCmd
.
DISCONNECT
});
// 回到初始界面
// 回到初始界面
navigate
(
"
/
"
);
navigate
(
"
/
"
);
}
}
}
}
...
...
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