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
049ef43e
Commit
049ef43e
authored
Sep 18, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
succeed in connecting with ygopro-proxy
parent
67c6710f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
4 deletions
+62
-4
src/WaitRoom.tsx
src/WaitRoom.tsx
+62
-4
No files found.
src/WaitRoom.tsx
View file @
049ef43e
import
React
from
"
react
"
;
import
React
,
{
useRef
,
useEffect
}
from
"
react
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
ygopro
}
from
"
./api/ocgcore
"
;
export
default
function
WaitRoom
()
{
export
default
function
WaitRoom
()
{
const
params
=
useParams
<
{
const
params
=
useParams
<
{
player
:
string
;
player
?
:
string
;
passWd
:
string
;
passWd
?
:
string
;
ip
:
string
;
ip
?
:
string
;
}
>
();
}
>
();
const
ws
=
useRef
<
WebSocket
|
null
>
(
null
);
const
{
player
,
passWd
,
ip
}
=
params
;
useEffect
(()
=>
{
if
(
!
ws
.
current
)
{
ws
.
current
=
new
WebSocket
(
"
ws://
"
+
ip
);
}
ws
.
current
.
onopen
=
()
=>
{
console
.
log
(
"
websocket open
"
);
if
(
player
!=
null
&&
player
.
length
!=
0
&&
passWd
!=
null
&&
passWd
.
length
!=
0
&&
ws
.
current
)
{
const
wsCurrent
=
ws
.
current
;
const
playerInfo
=
new
ygopro
.
YgoCtosMsg
({
ctos_player_info
:
new
ygopro
.
CtosPlayerInfo
({
name
:
player
})
});
wsCurrent
.
send
(
playerInfo
.
serialize
());
const
joinGame
=
new
ygopro
.
YgoCtosMsg
({
ctos_join_game
:
new
ygopro
.
CtosJoinGame
({
version
:
4947
,
// todo: use config
gameid
:
0
,
passwd
:
passWd
})
});
wsCurrent
.
send
(
joinGame
.
serialize
());
}
};
ws
.
current
.
onclose
=
()
=>
{
console
.
log
(
"
websocket closed
"
);
};
ws
.
current
.
onmessage
=
e
=>
{
console
.
log
(
"
websocket read message:
"
+
e
.
data
);
};
const
wsCurrent
=
ws
.
current
;
return
()
=>
{
if
(
wsCurrent
.
readyState
==
1
)
{
wsCurrent
.
close
();
}
};
},
[
ws
]);
return
(
return
(
<
div
>
<
div
>
<
p
>
player:
{
params
.
player
}
</
p
>
<
p
>
player:
{
params
.
player
}
</
p
>
...
...
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