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
223d6dc0
Commit
223d6dc0
authored
Oct 09, 2024
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add 408 hint
parent
3ae86dcb
Pipeline
#30313
passed with stages
in 7 minutes and 18 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
13 deletions
+34
-13
src/infra/stream.ts
src/infra/stream.ts
+5
-2
src/middleware/socket.ts
src/middleware/socket.ts
+8
-6
src/service/onSocketOpen.ts
src/service/onSocketOpen.ts
+6
-5
src/ui/Match/MatchModal/index.tsx
src/ui/Match/MatchModal/index.tsx
+13
-0
src/ui/Match/util.ts
src/ui/Match/util.ts
+2
-0
No files found.
src/infra/stream.ts
View file @
223d6dc0
...
@@ -8,10 +8,13 @@ export class WebSocketStream {
...
@@ -8,10 +8,13 @@ export class WebSocketStream {
public
ws
:
WebSocket
;
public
ws
:
WebSocket
;
stream
:
ReadableStream
;
stream
:
ReadableStream
;
constructor
(
ip
:
string
,
onWsOpen
?:
(
ws
:
WebSocket
,
ev
:
Event
)
=>
any
)
{
constructor
(
ip
:
string
,
onWsOpen
?:
(
conn
:
WebSocketStream
,
ev
:
Event
)
=>
any
,
)
{
this
.
ws
=
new
WebSocket
(
"
wss://
"
+
ip
);
this
.
ws
=
new
WebSocket
(
"
wss://
"
+
ip
);
if
(
onWsOpen
)
{
if
(
onWsOpen
)
{
this
.
ws
.
onopen
=
(
e
)
=>
onWsOpen
(
this
.
ws
,
e
);
this
.
ws
.
onopen
=
(
e
)
=>
onWsOpen
(
this
,
e
);
}
}
this
.
ws
.
onerror
=
(
e
)
=>
{
this
.
ws
.
onerror
=
(
e
)
=>
{
if
(
e
instanceof
ErrorEvent
)
{
if
(
e
instanceof
ErrorEvent
)
{
...
...
src/middleware/socket.ts
View file @
223d6dc0
...
@@ -13,11 +13,13 @@ export function initSocket(initInfo: {
...
@@ -13,11 +13,13 @@ export function initSocket(initInfo: {
ip
:
string
;
ip
:
string
;
player
:
string
;
player
:
string
;
passWd
:
string
;
passWd
:
string
;
customOnConnected
?:
(
conn
:
WebSocketStream
)
=>
void
;
}):
WebSocketStream
{
}):
WebSocketStream
{
const
{
ip
,
player
,
passWd
}
=
initInfo
;
const
{
ip
,
player
,
passWd
,
customOnConnected
}
=
initInfo
;
return
new
WebSocketStream
(
ip
,
(
conn
,
_event
)
=>
return
new
WebSocketStream
(
ip
,
(
conn
,
_event
)
=>
{
handleSocketOpen
(
conn
,
ip
,
player
,
passWd
),
handleSocketOpen
(
conn
,
ip
,
player
,
passWd
);
);
customOnConnected
&&
customOnConnected
(
conn
);
});
}
}
export
function
initReplaySocket
(
replayInfo
:
{
export
function
initReplaySocket
(
replayInfo
:
{
...
@@ -27,8 +29,8 @@ export function initReplaySocket(replayInfo: {
...
@@ -27,8 +29,8 @@ export function initReplaySocket(replayInfo: {
const
{
url
,
data
}
=
replayInfo
;
const
{
url
,
data
}
=
replayInfo
;
return
new
WebSocketStream
(
url
,
(
conn
,
_event
)
=>
{
return
new
WebSocketStream
(
url
,
(
conn
,
_event
)
=>
{
console
.
info
(
"
replay websocket open.
"
);
console
.
info
(
"
replay websocket open.
"
);
conn
.
binaryType
=
"
arraybuffer
"
;
conn
.
ws
.
binaryType
=
"
arraybuffer
"
;
conn
.
send
(
data
);
conn
.
ws
.
send
(
data
);
});
});
}
}
...
...
src/service/onSocketOpen.ts
View file @
223d6dc0
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
* */
* */
import
{
sendJoinGame
,
sendPlayerInfo
}
from
"
@/api
"
;
import
{
sendJoinGame
,
sendPlayerInfo
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
WebSocketStream
}
from
"
@/infra
"
;
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
/*
/*
...
@@ -12,17 +13,17 @@ const NeosConfig = useConfig();
...
@@ -12,17 +13,17 @@ const NeosConfig = useConfig();
*
*
* */
* */
export
default
function
handleSocketOpen
(
export
default
function
handleSocketOpen
(
ws
:
WebSocket
|
undefined
,
conn
:
WebSocketStream
|
undefined
,
_ip
:
string
,
_ip
:
string
,
player
:
string
,
player
:
string
,
passWd
:
string
,
passWd
:
string
,
)
{
)
{
console
.
log
(
"
WebSocket opened.
"
);
console
.
log
(
"
WebSocket opened.
"
);
if
(
ws
&&
ws
.
readyState
===
1
)
{
if
(
conn
&&
conn
.
ws
.
readyState
===
1
)
{
ws
.
binaryType
=
"
arraybuffer
"
;
conn
.
ws
.
binaryType
=
"
arraybuffer
"
;
sendPlayerInfo
(
ws
,
player
);
sendPlayerInfo
(
conn
.
ws
,
player
);
sendJoinGame
(
ws
,
NeosConfig
.
version
,
passWd
);
sendJoinGame
(
conn
.
ws
,
NeosConfig
.
version
,
passWd
);
}
}
}
}
src/ui/Match/MatchModal/index.tsx
View file @
223d6dc0
...
@@ -4,7 +4,9 @@ import { useTranslation } from "react-i18next";
...
@@ -4,7 +4,9 @@ import { useTranslation } from "react-i18next";
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
sendChat
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
WebSocketStream
}
from
"
@/infra
"
;
import
{
accountStore
,
roomStore
}
from
"
@/stores
"
;
import
{
accountStore
,
roomStore
}
from
"
@/stores
"
;
import
{
Select
}
from
"
@/ui/Shared
"
;
import
{
Select
}
from
"
@/ui/Shared
"
;
...
@@ -55,6 +57,16 @@ export const MatchModal: React.FC = ({}) => {
...
@@ -55,6 +57,16 @@ export const MatchModal: React.FC = ({}) => {
const
handlePasswdChange
=
(
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handlePasswdChange
=
(
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setPasswd
(
event
.
target
.
value
);
setPasswd
(
event
.
target
.
value
);
};
};
const
send408Hint
=
(
conn
:
WebSocketStream
)
=>
{
setTimeout
(
()
=>
sendChat
(
conn
,
"
由于技术原因,408环境卡池内可用卡牌暂无法直接标出,某些卡片实际使用的是旧效果,例如混沌之黑魔术师、多尔·多拉、死之卡组破坏病毒...
"
,
),
1000
,
);
};
const
handleSubmit
=
async
()
=>
{
const
handleSubmit
=
async
()
=>
{
setConfirmLoading
(
true
);
setConfirmLoading
(
true
);
...
@@ -63,6 +75,7 @@ export const MatchModal: React.FC = ({}) => {
...
@@ -63,6 +75,7 @@ export const MatchModal: React.FC = ({}) => {
ip
:
genServerAddress
(
serverId
),
ip
:
genServerAddress
(
serverId
),
passWd
:
passwd
,
passWd
:
passwd
,
enableKuriboh
,
enableKuriboh
,
customOnConnected
:
serverId
===
ENV_408
?
send408Hint
:
undefined
,
});
});
};
};
...
...
src/ui/Match/util.ts
View file @
223d6dc0
...
@@ -3,6 +3,7 @@ import rustInit from "rust-src";
...
@@ -3,6 +3,7 @@ import rustInit from "rust-src";
import
{
initStrings
,
initSuperPrerelease
}
from
"
@/api
"
;
import
{
initStrings
,
initSuperPrerelease
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
getUIContainer
,
initUIContainer
}
from
"
@/container/compat
"
;
import
{
getUIContainer
,
initUIContainer
}
from
"
@/container/compat
"
;
import
{
WebSocketStream
}
from
"
@/infra
"
;
import
{
initReplaySocket
,
initSocket
}
from
"
@/middleware/socket
"
;
import
{
initReplaySocket
,
initSocket
}
from
"
@/middleware/socket
"
;
import
{
import
{
pollSocketLooper
,
pollSocketLooper
,
...
@@ -21,6 +22,7 @@ export const connectSrvpro = async (params: {
...
@@ -21,6 +22,7 @@ export const connectSrvpro = async (params: {
enableKuriboh
?:
boolean
;
enableKuriboh
?:
boolean
;
replay
?:
boolean
;
replay
?:
boolean
;
replayData
?:
ArrayBuffer
;
replayData
?:
ArrayBuffer
;
customOnConnected
?:
(
conn
:
WebSocketStream
)
=>
void
;
})
=>
{
})
=>
{
// 初始化wasm
// 初始化wasm
const
url
=
const
url
=
...
...
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