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
610fcd05
Commit
610fcd05
authored
Oct 23, 2022
by
Chunchi Che
Committed by
WANG HE
Dec 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3dd74577
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
108 additions
and
22 deletions
+108
-22
src/api/ocgcore/ocgAdapter/ctos/ctosJoinGame.ts
src/api/ocgcore/ocgAdapter/ctos/ctosJoinGame.ts
+5
-5
src/api/ocgcore/ocgAdapter/ctos/ctosPlayerInfo.ts
src/api/ocgcore/ocgAdapter/ctos/ctosPlayerInfo.ts
+4
-3
src/api/ocgcore/ocgAdapter/packet.ts
src/api/ocgcore/ocgAdapter/packet.ts
+4
-8
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+1
-0
src/api/ocgcore/ocgAdapter/stoc/stocChat.ts
src/api/ocgcore/ocgAdapter/stoc/stocChat.ts
+23
-0
src/api/ocgcore/ocgAdapter/stoc/stocJoinGame.ts
src/api/ocgcore/ocgAdapter/stoc/stocJoinGame.ts
+2
-2
src/api/ocgcore/ocgAdapter/util.ts
src/api/ocgcore/ocgAdapter/util.ts
+58
-0
src/api/ocgcore/ocgHelper.ts
src/api/ocgcore/ocgHelper.ts
+2
-2
src/service/onSocketMessage.ts
src/service/onSocketMessage.ts
+9
-2
No files found.
src/api/ocgcore/ocgAdapter/ctosJoinGame.ts
→
src/api/ocgcore/ocgAdapter/ctos
/ctos
JoinGame.ts
View file @
610fcd05
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
ygoProPacket
}
from
"
./packet
"
;
import
{
CTOS_JOIN_GAME
}
from
"
./protoDecl
"
;
import
{
ygopro
}
from
"
../../idl/ocgcore
"
;
import
{
ygoProPacket
}
from
"
../packet
"
;
import
{
CTOS_JOIN_GAME
}
from
"
../protoDecl
"
;
import
{
strEncodeUTF16
}
from
"
../util
"
;
const
littleEndian
:
boolean
=
true
;
export
default
class
CtosJoinGamePacket
extends
ygoProPacket
{
constructor
(
pb
:
ygopro
.
YgoCtosMsg
)
{
const
encoder
=
new
TextEncoder
();
const
joinGame
=
pb
.
ctos_join_game
;
const
version
=
joinGame
.
version
;
const
gameId
=
joinGame
.
gameid
;
const
passWd
=
encoder
.
encode
(
joinGame
.
passwd
);
const
passWd
=
strEncodeUTF16
(
joinGame
.
passwd
);
const
exDataLen
=
2
+
4
+
passWd
.
length
;
const
exData
=
new
Uint8Array
(
exDataLen
);
...
...
src/api/ocgcore/ocgAdapter/ctosPlayerInfo.ts
→
src/api/ocgcore/ocgAdapter/ctos
/ctos
PlayerInfo.ts
View file @
610fcd05
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
ygoProPacket
}
from
"
./packet
"
;
import
{
CTOS_PLAYER_INFO
}
from
"
./protoDecl
"
;
import
{
ygopro
}
from
"
../../idl/ocgcore
"
;
import
{
ygoProPacket
}
from
"
../packet
"
;
import
{
CTOS_PLAYER_INFO
}
from
"
../protoDecl
"
;
import
{
strEncodeUTF16
}
from
"
../util
"
;
export
default
class
CtosPlayerInfoPacket
extends
ygoProPacket
{
constructor
(
pb
:
ygopro
.
YgoCtosMsg
)
{
...
...
src/api/ocgcore/ocgAdapter/packet.ts
View file @
610fcd05
...
...
@@ -15,16 +15,12 @@ export class ygoProPacket {
}
serialize
():
Uint8Array
{
const
packetLen
=
this
.
packetLen
||
0
;
const
proto
=
this
.
proto
||
0
;
const
exData
=
this
.
exData
||
new
Uint8Array
();
const
array
=
new
Uint8Array
(
packetLen
+
2
);
const
array
=
new
Uint8Array
(
this
.
packetLen
+
2
);
const
dataView
=
new
DataView
(
array
.
buffer
);
dataView
.
setUint16
(
0
,
packetLen
,
littleEndian
);
dataView
.
setUint8
(
2
,
proto
);
array
.
slice
(
3
,
packetLen
+
2
).
set
(
exData
);
dataView
.
setUint16
(
0
,
this
.
packetLen
,
littleEndian
);
dataView
.
setUint8
(
2
,
this
.
proto
);
array
.
slice
(
3
,
this
.
packetLen
+
2
).
set
(
this
.
exData
);
return
array
;
}
...
...
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
610fcd05
...
...
@@ -2,3 +2,4 @@ export const CTOS_PLAYER_INFO = 16;
export
const
CTOS_JOIN_GAME
=
18
;
export
const
STOC_JOIN_GAME
=
18
;
export
const
STOC_CHAT
=
25
;
src/api/ocgcore/ocgAdapter/stoc/stocChat.ts
0 → 100644
View file @
610fcd05
import
{
ygopro
}
from
"
../../idl/ocgcore
"
;
import
{
ygoProPacket
,
ygoProtobuf
}
from
"
../packet
"
;
import
{
utf8ArrayToStr
}
from
"
../util
"
;
export
default
class
StocChatPB
implements
ygoProtobuf
{
packet
:
ygoProPacket
;
constructor
(
packet
:
ygoProPacket
)
{
this
.
packet
=
packet
;
}
adapt
():
ygopro
.
YgoStocMsg
{
const
player
=
new
DataView
(
this
.
packet
.
exData
.
buffer
).
getInt16
(
0
,
true
);
const
msg
=
utf8ArrayToStr
(
this
.
packet
.
exData
.
slice
(
2
));
return
new
ygopro
.
YgoStocMsg
({
stoc_chat
:
new
ygopro
.
StocChat
({
player
,
msg
,
}),
});
}
}
src/api/ocgcore/ocgAdapter/stocJoinGame.ts
→
src/api/ocgcore/ocgAdapter/stoc
/stoc
JoinGame.ts
View file @
610fcd05
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
ygoProPacket
,
ygoProtobuf
}
from
"
./packet
"
;
import
{
ygopro
}
from
"
../
../
idl/ocgcore
"
;
import
{
ygoProPacket
,
ygoProtobuf
}
from
"
.
.
/packet
"
;
export
default
class
StocJoinGamePB
implements
ygoProtobuf
{
packet
:
ygoProPacket
;
...
...
src/api/ocgcore/ocgAdapter/util.ts
0 → 100644
View file @
610fcd05
const
UTF16_BUFFER_MAX_LEN
=
20
;
const
FILLING_TOKEN
:
number
=
0xcccc
;
export
function
strEncodeUTF16
(
str
:
string
)
{
let
buf
=
new
ArrayBuffer
(
UTF16_BUFFER_MAX_LEN
*
2
);
let
bufView
=
new
Uint16Array
(
buf
);
bufView
.
fill
(
FILLING_TOKEN
,
0
,
UTF16_BUFFER_MAX_LEN
);
for
(
let
i
=
0
,
strLen
=
str
.
length
;
i
<
strLen
&&
i
<
UTF16_BUFFER_MAX_LEN
;
i
++
)
{
bufView
[
i
]
=
str
.
charCodeAt
(
i
);
}
return
new
Uint8Array
(
buf
);
}
export
function
utf8ArrayToStr
(
array
:
Uint8Array
)
{
let
out
,
i
,
len
,
c
;
let
char2
,
char3
;
out
=
""
;
len
=
array
.
length
;
i
=
0
;
while
(
i
<
len
)
{
c
=
array
[
i
++
];
switch
(
c
>>
4
)
{
case
0
:
case
1
:
case
2
:
case
3
:
case
4
:
case
5
:
case
6
:
case
7
:
// 0xxxxxxx
out
+=
String
.
fromCharCode
(
c
);
break
;
case
12
:
case
13
:
// 110x xxxx 10xx xxxx
char2
=
array
[
i
++
];
out
+=
String
.
fromCharCode
(((
c
&
0x1f
)
<<
6
)
|
(
char2
&
0x3f
));
break
;
case
14
:
// 1110 xxxx 10xx xxxx 10xx xxxx
char2
=
array
[
i
++
];
char3
=
array
[
i
++
];
out
+=
String
.
fromCharCode
(
((
c
&
0x0f
)
<<
12
)
|
((
char2
&
0x3f
)
<<
6
)
|
((
char3
&
0x3f
)
<<
0
)
);
break
;
}
}
return
out
;
}
src/api/ocgcore/ocgHelper.ts
View file @
610fcd05
import
{
ygopro
}
from
"
./idl/ocgcore
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
../../middleware/socket
"
;
import
{
IDeck
}
from
"
../Card
"
;
import
playerInfoPacket
from
"
./ocgAdapter/ctosPlayerInfo
"
;
import
joinGamePacket
from
"
./ocgAdapter/ctosJoinGame
"
;
import
playerInfoPacket
from
"
./ocgAdapter/ctos
/ctos
PlayerInfo
"
;
import
joinGamePacket
from
"
./ocgAdapter/ctos
/ctos
JoinGame
"
;
export
function
sendUpdateDeck
(
deck
:
IDeck
)
{
const
updateDeck
=
new
ygopro
.
YgoCtosMsg
({
...
...
src/service/onSocketMessage.ts
View file @
610fcd05
...
...
@@ -6,11 +6,13 @@ import handleJoinGame from "./room/joinGame";
import
handleChat
from
"
./room/chat
"
;
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
"
;
import
StocJoinGame
from
"
../api/ocgcore/ocgAdapter/stoc/stocJoinGame
"
;
import
{
STOC_CHAT
,
STOC_JOIN_GAME
}
from
"
../api/ocgcore/ocgAdapter/protoDecl
"
;
import
StocChat
from
"
../api/ocgcore/ocgAdapter/stoc/stocChat
"
;
export
default
function
handleSocketMessage
(
e
:
MessageEvent
)
{
const
packet
=
new
ygoArrayBuilder
(
e
.
data
);
console
.
log
(
packet
);
let
pb
=
new
ygopro
.
YgoStocMsg
({});
switch
(
packet
.
proto
)
{
...
...
@@ -19,6 +21,11 @@ export default function handleSocketMessage(e: MessageEvent) {
break
;
}
case
STOC_CHAT
:
{
pb
=
new
StocChat
(
packet
).
adapt
();
break
;
}
default
:
{
break
;
}
...
...
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