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
fec7bf6f
Commit
fec7bf6f
authored
Oct 23, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add stoc joinGame adapt
parent
700e81a1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
9 deletions
+51
-9
src/api/ocgcore/ocgAdapter/ctosJoinGame.ts
src/api/ocgcore/ocgAdapter/ctosJoinGame.ts
+3
-4
src/api/ocgcore/ocgAdapter/ctosPlayerInfo.ts
src/api/ocgcore/ocgAdapter/ctosPlayerInfo.ts
+3
-4
src/api/ocgcore/ocgAdapter/packet.ts
src/api/ocgcore/ocgAdapter/packet.ts
+8
-0
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+4
-0
src/api/ocgcore/ocgAdapter/stocJoinGame.ts
src/api/ocgcore/ocgAdapter/stocJoinGame.ts
+17
-0
src/service/onSocketMessage.ts
src/service/onSocketMessage.ts
+16
-1
No files found.
src/api/ocgcore/ocgAdapter/ctosJoinGame.ts
View file @
fec7bf6f
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
ygoProPacket
}
from
"
./packet
"
;
import
{
ygoProPacket
}
from
"
./packet
"
;
import
{
CTOS_JOIN_GAME
}
from
"
./protoDecl
"
;
const
littleEndian
:
boolean
=
true
;
const
littleEndian
:
boolean
=
true
;
const
CtosJoinGame
=
18
;
export
default
class
CtosJoinGamePacket
extends
ygoProPacket
{
export
default
class
joinGamePacket
extends
ygoProPacket
{
constructor
(
pb
:
ygopro
.
YgoCtosMsg
)
{
constructor
(
pb
:
ygopro
.
YgoCtosMsg
)
{
const
encoder
=
new
TextEncoder
();
const
encoder
=
new
TextEncoder
();
const
joinGame
=
pb
.
ctos_join_game
;
const
joinGame
=
pb
.
ctos_join_game
;
...
@@ -25,6 +24,6 @@ export default class joinGamePacket extends ygoProPacket {
...
@@ -25,6 +24,6 @@ export default class joinGamePacket extends ygoProPacket {
dataView
.
setUint8
(
5
,
(
gameId
>>
32
)
&
0xff
);
dataView
.
setUint8
(
5
,
(
gameId
>>
32
)
&
0xff
);
exData
.
slice
(
6
,
exDataLen
).
set
(
passWd
);
exData
.
slice
(
6
,
exDataLen
).
set
(
passWd
);
super
(
exData
.
length
+
1
,
C
tosJoinGame
,
exData
);
super
(
exData
.
length
+
1
,
C
TOS_JOIN_GAME
,
exData
);
}
}
}
}
src/api/ocgcore/ocgAdapter/ctosPlayerInfo.ts
View file @
fec7bf6f
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
ygoProPacket
}
from
"
./packet
"
;
import
{
ygoProPacket
}
from
"
./packet
"
;
import
{
CTOS_PLAYER_INFO
}
from
"
./protoDecl
"
;
const
CtosPlayerInfo
=
16
;
// todo: move protos in one place
export
default
class
CtosPlayerInfoPacket
extends
ygoProPacket
{
export
default
class
playerInfoPacket
extends
ygoProPacket
{
constructor
(
pb
:
ygopro
.
YgoCtosMsg
)
{
constructor
(
pb
:
ygopro
.
YgoCtosMsg
)
{
const
encoder
=
new
TextEncoder
();
const
encoder
=
new
TextEncoder
();
const
player
=
pb
.
ctos_player_info
.
name
;
const
player
=
pb
.
ctos_player_info
.
name
;
const
exData
=
encoder
.
encode
(
player
);
const
exData
=
encoder
.
encode
(
player
);
super
(
exData
.
length
+
1
,
C
tosPlayerInfo
,
exData
);
super
(
exData
.
length
+
1
,
C
TOS_PLAYER_INFO
,
exData
);
}
}
}
}
src/api/ocgcore/ocgAdapter/packet.ts
View file @
fec7bf6f
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
const
littleEndian
:
boolean
=
true
;
const
littleEndian
:
boolean
=
true
;
const
PACKET_MIN_LEN
=
3
;
const
PACKET_MIN_LEN
=
3
;
...
@@ -47,3 +49,9 @@ export class ygoArrayBuilder extends ygoProPacket {
...
@@ -47,3 +49,9 @@ export class ygoArrayBuilder extends ygoProPacket {
}
}
}
}
}
}
export
interface
ygoProtobuf
{
readonly
packet
:
ygoProPacket
;
adapt
():
ygopro
.
YgoStocMsg
;
}
src/api/ocgcore/ocgAdapter/protoDecl.ts
0 → 100644
View file @
fec7bf6f
export
const
CTOS_PLAYER_INFO
=
16
;
export
const
CTOS_JOIN_GAME
=
18
;
export
const
STOC_JOIN_GAME
=
18
;
src/api/ocgcore/ocgAdapter/stocJoinGame.ts
0 → 100644
View file @
fec7bf6f
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
ygoProPacket
,
ygoProtobuf
}
from
"
./packet
"
;
export
default
class
StocJoinGamePB
implements
ygoProtobuf
{
packet
:
ygoProPacket
;
constructor
(
packet
:
ygoProPacket
)
{
this
.
packet
=
packet
;
}
adapt
():
ygopro
.
YgoStocMsg
{
// todo
return
new
ygopro
.
YgoStocMsg
({
stoc_join_game
:
new
ygopro
.
StocJoinGame
({}),
});
}
}
src/service/onSocketMessage.ts
View file @
fec7bf6f
...
@@ -5,9 +5,24 @@ import handleHsPlayerEnter from "./room/hsPlayerEnter";
...
@@ -5,9 +5,24 @@ import handleHsPlayerEnter from "./room/hsPlayerEnter";
import
handleJoinGame
from
"
./room/joinGame
"
;
import
handleJoinGame
from
"
./room/joinGame
"
;
import
handleChat
from
"
./room/chat
"
;
import
handleChat
from
"
./room/chat
"
;
import
handleHsWatchChange
from
"
./room/hsWatchChange
"
;
import
handleHsWatchChange
from
"
./room/hsWatchChange
"
;
import
{
ygoArrayBuilder
}
from
"
../api/ocgcore/ocgAdapter/packet
"
;
import
StocJoinGame
from
"
../api/ocgcore/ocgAdapter/stocJoinGame
"
;
import
{
STOC_JOIN_GAME
}
from
"
../api/ocgcore/ocgAdapter/protoDecl
"
;
export
default
function
handleSocketMessage
(
e
:
MessageEvent
)
{
export
default
function
handleSocketMessage
(
e
:
MessageEvent
)
{
const
pb
=
ygopro
.
YgoStocMsg
.
deserializeBinary
(
e
.
data
);
const
packet
=
new
ygoArrayBuilder
(
e
.
data
);
let
pb
=
new
ygopro
.
YgoStocMsg
({});
switch
(
packet
.
proto
)
{
case
STOC_JOIN_GAME
:
{
pb
=
new
StocJoinGame
(
packet
).
adapt
();
break
;
}
default
:
{
break
;
}
}
switch
(
pb
.
msg
)
{
switch
(
pb
.
msg
)
{
case
"
stoc_join_game
"
:
{
case
"
stoc_join_game
"
:
{
...
...
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