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
e200c465
Commit
e200c465
authored
Sep 12, 2022
by
Chunchi Che
Committed by
GitHub
Sep 12, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request
#1
from DarkNeos/dev
Dev
parents
7baabff9
5b09d7aa
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
265 additions
and
207 deletions
+265
-207
src/JoinHome.tsx
src/JoinHome.tsx
+40
-7
src/api/ocgcore.proto
src/api/ocgcore.proto
+12
-8
src/api/ocgcore.ts
src/api/ocgcore.ts
+213
-192
No files found.
src/JoinHome.tsx
View file @
e200c465
...
...
@@ -3,8 +3,8 @@ import { ygopro } from "./api/ocgcore";
export
default
function
JoinHome
(
props
:
{
addr
:
string
})
{
const
ws
=
useRef
<
WebSocket
|
null
>
(
null
);
const
[
user
n
ame
,
setUsername
]
=
useState
(
""
);
const
[
pass
w
d
,
setPasswd
]
=
useState
(
""
);
const
[
user
N
ame
,
setUsername
]
=
useState
(
""
);
const
[
pass
W
d
,
setPasswd
]
=
useState
(
""
);
const
[
isJoined
,
setJoined
]
=
useState
(
false
);
useEffect
(()
=>
{
...
...
@@ -24,8 +24,12 @@ export default function JoinHome(props: { addr: string }) {
const
wsCurrent
=
ws
.
current
;
return
()
=>
wsCurrent
.
close
();
},
[]);
return
()
=>
{
if
(
wsCurrent
.
readyState
==
1
)
{
wsCurrent
.
close
();
}
};
},
[
ws
]);
let
handleUsernameChange
=
(
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setUsername
(
event
.
target
.
value
);
...
...
@@ -43,7 +47,36 @@ export default function JoinHome(props: { addr: string }) {
}
else
{
const
wsCurrent
=
ws
.
current
;
// todo
if
(
userName
!=
null
&&
userName
.
length
!=
0
&&
passWd
!=
null
&&
passWd
.
length
!=
0
)
{
console
.
log
(
"
ready to send playerInfo and joinGame packet, userName=
"
+
userName
+
"
, passWd=
"
+
passWd
);
const
playerInfo
=
new
ygopro
.
YgoCtosMsg
({
ctos_player_info
:
new
ygopro
.
CtosPlayerInfo
({
name
:
userName
,
}),
});
wsCurrent
.
send
(
playerInfo
.
serialize
());
const
joinGame
=
new
ygopro
.
YgoCtosMsg
({
ctos_join_game
:
new
ygopro
.
CtosJoinGame
({
version
:
4947
,
gameid
:
0
,
passwd
:
passWd
,
}),
});
wsCurrent
.
send
(
joinGame
.
serialize
());
}
}
};
...
...
@@ -53,7 +86,7 @@ export default function JoinHome(props: { addr: string }) {
<
input
type=
"text"
title=
"username"
value=
{
user
n
ame
}
value=
{
user
N
ame
}
onChange=
{
handleUsernameChange
}
></
input
>
</
p
>
...
...
@@ -61,7 +94,7 @@ export default function JoinHome(props: { addr: string }) {
<
input
type=
"text"
title=
"passwd"
value=
{
pass
w
d
}
value=
{
pass
W
d
}
onChange=
{
handlePasswdChange
}
></
input
>
</
p
>
...
...
src/api/ocgcore.proto
View file @
e200c465
...
...
@@ -5,17 +5,21 @@ option go_package = "DarkNeos/ygopropb";
message
YgoCtosMsg
{
oneof
msg
{
CtosPlayerInfo
ctos_player_info
=
2
;
CtosJoinGame
ctos_join_game
=
3
;
CtosUpdateDeck
ctos_update_deck
=
4
;
StocJoinGame
stoc_join_game
=
101
;
StocChat
stoc_chat
=
102
;
StocHsPlayerEnter
stoc_hs_player_enter
=
103
;
StocTypeChange
stoc_type_change
=
104
;
CtosPlayerInfo
ctos_player_info
=
1
;
CtosJoinGame
ctos_join_game
=
2
;
CtosUpdateDeck
ctos_update_deck
=
3
;
}
}
message
YgoStocMsg
{
oneof
msg
{
StocJoinGame
stoc_join_game
=
1
;
StocChat
stoc_chat
=
2
;
StocHsPlayerEnter
stoc_hs_player_enter
=
3
;
StocTypeChange
stoc_type_change
=
4
;
}
}
// ----- CTOS -----
message
CtosPlayerInfo
{
...
...
src/api/ocgcore.ts
View file @
e200c465
This diff is collapsed.
Click to expand it.
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