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
1ec3eb3a
Commit
1ec3eb3a
authored
Mar 07, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/client/chat' into 'main'
Feat/client/chat See merge request
!121
parents
5d7ae541
5ae71ed4
Pipeline
#20509
passed with stages
in 6 minutes and 19 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
175 additions
and
8 deletions
+175
-8
neos-protobuf
neos-protobuf
+1
-1
src/api/ocgcore/idl/ocgcore.ts
src/api/ocgcore/idl/ocgcore.ts
+136
-3
src/api/ocgcore/ocgAdapter/ctos/ctosChat.ts
src/api/ocgcore/ocgAdapter/ctos/ctosChat.ts
+19
-0
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+1
-0
src/api/ocgcore/ocgHelper.ts
src/api/ocgcore/ocgHelper.ts
+10
-0
src/ui/Duel/sendBox.tsx
src/ui/Duel/sendBox.tsx
+5
-1
src/ui/Duel/timeLine.tsx
src/ui/Duel/timeLine.tsx
+3
-3
No files found.
neos-protobuf
@
308767ca
Subproject commit
fc8be2c49a17c13ad25040e99293fc29d8b9f4e1
Subproject commit
308767ca7ca67e28f99a45687a1cc8209e91453d
src/api/ocgcore/idl/ocgcore.ts
View file @
1ec3eb3a
...
...
@@ -363,7 +363,7 @@ export namespace ygopro {
}
}
export class YgoCtosMsg extends pb_1.Message {
#one_of_decls: number[][] = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]];
#one_of_decls: number[][] = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10
, 11
]];
constructor(
data?:
| any[]
...
...
@@ -379,6 +379,7 @@ export namespace ygopro {
ctos_tp_result?: never;
ctos_time_confirm?: never;
ctos_response?: never;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
...
...
@@ -391,6 +392,7 @@ export namespace ygopro {
ctos_tp_result?: never;
ctos_time_confirm?: never;
ctos_response?: never;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
...
...
@@ -403,6 +405,7 @@ export namespace ygopro {
ctos_tp_result?: never;
ctos_time_confirm?: never;
ctos_response?: never;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
...
...
@@ -415,6 +418,7 @@ export namespace ygopro {
ctos_tp_result?: never;
ctos_time_confirm?: never;
ctos_response?: never;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
...
...
@@ -427,6 +431,7 @@ export namespace ygopro {
ctos_tp_result?: never;
ctos_time_confirm?: never;
ctos_response?: never;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
...
...
@@ -439,6 +444,7 @@ export namespace ygopro {
ctos_tp_result?: never;
ctos_time_confirm?: never;
ctos_response?: never;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
...
...
@@ -451,6 +457,7 @@ export namespace ygopro {
ctos_tp_result?: never;
ctos_time_confirm?: never;
ctos_response?: never;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
...
...
@@ -463,6 +470,7 @@ export namespace ygopro {
ctos_tp_result?: CtosTpResult;
ctos_time_confirm?: never;
ctos_response?: never;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
...
...
@@ -475,6 +483,7 @@ export namespace ygopro {
ctos_tp_result?: never;
ctos_time_confirm?: CtosTimeConfirm;
ctos_response?: never;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
...
...
@@ -487,6 +496,20 @@ export namespace ygopro {
ctos_tp_result?: never;
ctos_time_confirm?: never;
ctos_response?: CtosGameMsgResponse;
ctos_chat?: never;
}
| {
ctos_player_info?: never;
ctos_join_game?: never;
ctos_update_deck?: never;
ctos_hs_ready?: never;
ctos_hs_start?: never;
ctos_hs_not_ready?: never;
ctos_hand_result?: never;
ctos_tp_result?: never;
ctos_time_confirm?: never;
ctos_response?: never;
ctos_chat?: CtosChat;
}
))
) {
...
...
@@ -536,6 +559,9 @@ export namespace ygopro {
if ("ctos_response" in data && data.ctos_response != undefined) {
this.ctos_response = data.ctos_response;
}
if ("ctos_chat" in data && data.ctos_chat != undefined) {
this.ctos_chat = data.ctos_chat;
}
}
}
get ctos_player_info() {
...
...
@@ -660,6 +686,15 @@ export namespace ygopro {
get has_ctos_response() {
return pb_1.Message.getField(this, 10) != null;
}
get ctos_chat() {
return pb_1.Message.getWrapperField(this, CtosChat, 11) as CtosChat;
}
set ctos_chat(value: CtosChat) {
pb_1.Message.setOneofWrapperField(this, 11, this.#one_of_decls[0], value);
}
get has_ctos_chat() {
return pb_1.Message.getField(this, 11) != null;
}
get msg() {
const cases: {
[index: number]:
...
...
@@ -673,7 +708,8 @@ export namespace ygopro {
| "ctos_hand_result"
| "ctos_tp_result"
| "ctos_time_confirm"
| "ctos_response";
| "ctos_response"
| "ctos_chat";
} = {
0: "none",
1: "ctos_player_info",
...
...
@@ -686,9 +722,10 @@ export namespace ygopro {
8: "ctos_tp_result",
9: "ctos_time_confirm",
10: "ctos_response",
11: "ctos_chat",
};
return cases[
pb_1.Message.computeOneofCase(this, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
pb_1.Message.computeOneofCase(this, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10
, 11
])
];
}
static fromObject(data: {
...
...
@@ -702,6 +739,7 @@ export namespace ygopro {
ctos_tp_result?: ReturnType<typeof CtosTpResult.prototype.toObject>;
ctos_time_confirm?: ReturnType<typeof CtosTimeConfirm.prototype.toObject>;
ctos_response?: ReturnType<typeof CtosGameMsgResponse.prototype.toObject>;
ctos_chat?: ReturnType<typeof CtosChat.prototype.toObject>;
}): YgoCtosMsg {
const message = new YgoCtosMsg({});
if (data.ctos_player_info != null) {
...
...
@@ -746,6 +784,9 @@ export namespace ygopro {
data.ctos_response
);
}
if (data.ctos_chat != null) {
message.ctos_chat = CtosChat.fromObject(data.ctos_chat);
}
return message;
}
toObject() {
...
...
@@ -766,6 +807,7 @@ export namespace ygopro {
ctos_response?: ReturnType<
typeof CtosGameMsgResponse.prototype.toObject
>;
ctos_chat?: ReturnType<typeof CtosChat.prototype.toObject>;
} = {};
if (this.ctos_player_info != null) {
data.ctos_player_info = this.ctos_player_info.toObject();
...
...
@@ -797,6 +839,9 @@ export namespace ygopro {
if (this.ctos_response != null) {
data.ctos_response = this.ctos_response.toObject();
}
if (this.ctos_chat != null) {
data.ctos_chat = this.ctos_chat.toObject();
}
return data;
}
serialize(): Uint8Array;
...
...
@@ -843,6 +888,10 @@ export namespace ygopro {
writer.writeMessage(10, this.ctos_response, () =>
this.ctos_response.serialize(writer)
);
if (this.has_ctos_chat)
writer.writeMessage(11, this.ctos_chat, () =>
this.ctos_chat.serialize(writer)
);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): YgoCtosMsg {
...
...
@@ -922,6 +971,12 @@ export namespace ygopro {
CtosGameMsgResponse.deserialize(reader))
);
break;
case 11:
reader.readMessage(
message.ctos_chat,
() => (message.ctos_chat = CtosChat.deserialize(reader))
);
break;
default:
reader.skipField();
}
...
...
@@ -2419,6 +2474,84 @@ export namespace ygopro {
return CtosTimeConfirm.deserialize(bytes);
}
}
export class CtosChat extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
message?: string;
}
) {
super();
pb_1.Message.initialize(
this,
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == "object") {
if ("message" in data && data.message != undefined) {
this.message = data.message;
}
}
}
get message() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set message(value: string) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: { message?: string }): CtosChat {
const message = new CtosChat({});
if (data.message != null) {
message.message = data.message;
}
return message;
}
toObject() {
const data: {
message?: string;
} = {};
if (this.message != null) {
data.message = this.message;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.message.length) writer.writeString(1, this.message);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CtosChat {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new CtosChat();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.message = reader.readString();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CtosChat {
return CtosChat.deserialize(bytes);
}
}
export class CtosGameMsgResponse extends pb_1.Message {
#one_of_decls: number[][] = [[1, 2, 3, 4, 5, 6, 7, 8, 9]];
constructor(
...
...
src/api/ocgcore/ocgAdapter/ctos/ctosChat.ts
0 → 100644
View file @
1ec3eb3a
import
{
ygopro
}
from
"
../../idl/ocgcore
"
;
import
{
YgoProPacket
}
from
"
../packet
"
;
import
{
CTOS_CHAT
}
from
"
../protoDecl
"
;
import
{
strEncodeUTF16
}
from
"
../util
"
;
/*
* CTOS Chat
*
* @param message - 玩家发送的消息
*
* @usage - TODO*/
export
default
class
CtosChat
extends
YgoProPacket
{
constructor
(
pb
:
ygopro
.
YgoCtosMsg
)
{
const
message
=
pb
.
ctos_chat
.
message
;
const
exData
=
strEncodeUTF16
(
message
);
super
(
exData
.
length
+
1
,
CTOS_CHAT
,
exData
);
}
}
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
1ec3eb3a
...
...
@@ -11,6 +11,7 @@ export const CTOS_HAND_RESULT = 3;
export
const
CTOS_TP_RESULT
=
4
;
export
const
CTOS_TIME_CONFIRM
=
21
;
export
const
CTOS_RESPONSE
=
1
;
export
const
CTOS_CHAT
=
22
;
export
const
STOC_JOIN_GAME
=
18
;
export
const
STOC_CHAT
=
25
;
...
...
src/api/ocgcore/ocgHelper.ts
View file @
1ec3eb3a
...
...
@@ -14,6 +14,7 @@ import HandResult from "./ocgAdapter/ctos/ctosHandResult";
import
TpResult
from
"
./ocgAdapter/ctos/ctosTpResult
"
;
import
TimeConfirm
from
"
./ocgAdapter/ctos/ctosTimeConfirm
"
;
import
GameMsgResponse
from
"
./ocgAdapter/ctos/ctosGameMsgResponse/mod
"
;
import
Chat
from
"
./ocgAdapter/ctos/ctosChat
"
;
export
function
sendUpdateDeck
(
deck
:
IDeck
)
{
const
updateDeck
=
new
ygopro
.
YgoCtosMsg
({
...
...
@@ -119,6 +120,15 @@ export function sendTimeConfirm() {
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
}
export
function
sendChat
(
message
:
string
)
{
const
chat
=
new
ygopro
.
YgoCtosMsg
({
ctos_chat
:
new
ygopro
.
CtosChat
({
message
}),
});
const
payload
=
new
Chat
(
chat
).
serialize
();
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
}
export
function
sendSelectIdleCmdResponse
(
value
:
number
)
{
const
response
=
new
ygopro
.
YgoCtosMsg
({
ctos_response
:
new
ygopro
.
CtosGameMsgResponse
({
...
...
src/ui/Duel/sendBox.tsx
View file @
1ec3eb3a
import
React
,
{
useState
}
from
"
react
"
;
import
{
Input
,
Button
,
Row
,
Col
}
from
"
antd
"
;
import
{
SendOutlined
}
from
"
@ant-design/icons
"
;
import
{
sendChat
}
from
"
../../api/ocgcore/ocgHelper
"
;
const
SendBox
=
()
=>
{
const
[
content
,
setContent
]
=
useState
(
""
);
...
...
@@ -20,7 +21,10 @@ const SendBox = () => {
<
Col
>
<
Button
icon=
{
<
SendOutlined
/>
}
onClick=
{
()
=>
{}
}
onClick=
{
()
=>
{
sendChat
(
content
);
setContent
(
""
);
}
}
disabled=
{
!
content
}
/>
</
Col
>
...
...
src/ui/Duel/timeLine.tsx
View file @
1ec3eb3a
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
Timeline
,
TimelineItemProps
}
from
"
antd
"
;
import
{
Setting
Outlined
}
from
"
@ant-design/icons
"
;
import
{
Message
Outlined
}
from
"
@ant-design/icons
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
selectChat
}
from
"
../../reducers/chatSlice
"
;
...
...
@@ -12,9 +12,9 @@ const DuelTimeLine = () => {
setItems
((
prev
)
=>
prev
.
concat
([
{
dot
:
<
Setting
Outlined
/>,
dot
:
<
Message
Outlined
/>,
children
:
chat
,
color
:
"
red
"
,
color
:
"
green
"
,
},
])
);
...
...
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