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
love_飞影
Neos
Commits
a4c9a8a7
Commit
a4c9a8a7
authored
Oct 04, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
25eeb95c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
src/WaitRoom.tsx
src/WaitRoom.tsx
+27
-6
No files found.
src/WaitRoom.tsx
View file @
a4c9a8a7
import
React
,
{
useRef
,
useEffect
}
from
"
react
"
;
import
React
,
{
useRef
,
useEffect
,
useState
}
from
"
react
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
ygopro
}
from
"
./api/idl/ocgcore
"
;
import
{
ygopro
}
from
"
./api/idl/ocgcore
"
;
...
@@ -9,6 +9,9 @@ export default function WaitRoom() {
...
@@ -9,6 +9,9 @@ export default function WaitRoom() {
ip
?:
string
;
ip
?:
string
;
}
>
();
}
>
();
const
[
joined
,
setJoined
]
=
useState
<
string
>
(
"
false
"
);
const
[
chat
,
setChat
]
=
useState
<
string
>
(
""
);
const
ws
=
useRef
<
WebSocket
|
null
>
(
null
);
const
ws
=
useRef
<
WebSocket
|
null
>
(
null
);
const
{
player
,
passWd
,
ip
}
=
params
;
const
{
player
,
passWd
,
ip
}
=
params
;
...
@@ -41,8 +44,27 @@ export default function WaitRoom() {
...
@@ -41,8 +44,27 @@ export default function WaitRoom() {
};
};
ws
.
current
.
onmessage
=
e
=>
{
ws
.
current
.
onmessage
=
e
=>
{
const
pb
:
ygopro
.
YgoStocMsg
=
ygopro
.
YgoStocMsg
.
deserializeBinary
(
e
.
data
);
const
pb
=
ygopro
.
YgoStocMsg
.
deserializeBinary
(
e
.
data
);
console
.
log
(
"
websocket read message:
"
+
pb
);
switch
(
pb
.
msg
)
{
case
"
stoc_join_game
"
:
{
const
msg
=
pb
.
stoc_join_game
;
console
.
log
(
"
joinGame msg=
"
+
msg
);
setJoined
(
"
true
"
);
break
;
}
case
"
stoc_chat
"
:
{
const
chat
=
pb
.
stoc_chat
;
setChat
(
chat
.
msg
);
break
;
}
default
:
{
break
;
}
}
};
};
const
wsCurrent
=
ws
.
current
;
const
wsCurrent
=
ws
.
current
;
...
@@ -56,9 +78,8 @@ export default function WaitRoom() {
...
@@ -56,9 +78,8 @@ export default function WaitRoom() {
return
(
return
(
<
div
>
<
div
>
<
p
>
player:
{
params
.
player
}
</
p
>
<
p
>
joined:
{
joined
}
</
p
>
<
p
>
ip:
{
params
.
ip
}
</
p
>
<
p
>
chat:
{
chat
}
</
p
>
<
p
>
passwd:
{
params
.
passWd
}
</
p
>
</
div
>
</
div
>
);
);
}
}
...
...
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