166 lines
3.2 KiB
TypeScript
166 lines
3.2 KiB
TypeScript
|
import { NetRequest } from "@/Engine/CatanEngine/NetManagerV2/NetRequest";
|
||
|
|
||
|
// #region Request
|
||
|
|
||
|
export type RpcChatSendRequest = [
|
||
|
channel: [channelType: ChannelType | number, uuid?: string],
|
||
|
message: messageData,
|
||
|
]
|
||
|
|
||
|
export type RpcChatSendResponse = null
|
||
|
|
||
|
/**聊天室發言角色(還未有客服小姐姐分類) */
|
||
|
export enum Role {
|
||
|
Normal,
|
||
|
}
|
||
|
|
||
|
/** 聊天室 傳送聊天訊息 協定 */
|
||
|
export class ChatSendRequest extends NetRequest<RpcChatSendRequest, RpcChatSendResponse> {
|
||
|
get Method(): string {
|
||
|
return "chat.send";
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param {ChannelType} channelType 頻道
|
||
|
* @param {string} msg 訊息
|
||
|
*/
|
||
|
constructor(channelType: ChannelType, msg: string, type: MsgType, uuid?: number) {
|
||
|
super();
|
||
|
const channelData: [channelType: ChannelType, uuid?: string] = [channelType];
|
||
|
uuid && channelData.push(uuid);
|
||
|
this.Data = [channelData, [type, msg]];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export type RpcChatMessageResponse = [
|
||
|
channelType: ChannelType,
|
||
|
from: [
|
||
|
aId: number,
|
||
|
name: string,
|
||
|
avatar: 0 | 1,
|
||
|
vip: number,
|
||
|
role: Role,
|
||
|
],
|
||
|
messageData: messageData,
|
||
|
timestamp: number
|
||
|
]
|
||
|
|
||
|
|
||
|
export type RpcChatLogRequest = [
|
||
|
channelType: ChannelType,
|
||
|
lastTime: number,
|
||
|
]
|
||
|
export type RpcChatLogResponse = [
|
||
|
channelType: ChannelType,
|
||
|
message: string,
|
||
|
]
|
||
|
/** 聊天室 頻道紀錄 協定 */
|
||
|
export class ChatLogRequest extends NetRequest<RpcChatLogRequest, RpcChatLogResponse> {
|
||
|
get Method(): string {
|
||
|
return "chat.log";
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param {ChannelType} channelType 頻道類型
|
||
|
* @param {number} lastTime 上次取得時間
|
||
|
*/
|
||
|
constructor(channelType: ChannelType, lastTime: number) {
|
||
|
super();
|
||
|
this.Data = [channelType, lastTime];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export type RpcChatReadRequest = number
|
||
|
export type RpcChatReadResponse = null
|
||
|
/** 聊天室 私訊已讀 協定 */
|
||
|
export class ChatReadRequest extends NetRequest<RpcChatReadRequest, RpcChatReadResponse> {
|
||
|
get Method(): string {
|
||
|
return "chat.read";
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param {number} aId aId
|
||
|
*/
|
||
|
constructor(aId: number) {
|
||
|
super();
|
||
|
this.Data = aId;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// #region Type
|
||
|
|
||
|
export type ChatLogData = [
|
||
|
channelType: ChannelType,
|
||
|
messageData: publicChatLogData[] | privateChatLogData[],
|
||
|
]
|
||
|
|
||
|
export type publicChatLogData = [
|
||
|
from: chatFromData,
|
||
|
messageData: messageData,
|
||
|
timestamp: number,
|
||
|
]
|
||
|
|
||
|
export type chatFromData = [
|
||
|
aId: number,
|
||
|
name: string,
|
||
|
avatar: 0 | 1,
|
||
|
vip: number,
|
||
|
role: Role,
|
||
|
]
|
||
|
|
||
|
export type privateChatLogData = [
|
||
|
senderAid: number,
|
||
|
receiveAid: number,
|
||
|
messageData: messageData,
|
||
|
timestamp: number,
|
||
|
isRead: boolean,
|
||
|
]
|
||
|
|
||
|
export type messageData = [type: MsgType, message: string]
|
||
|
|
||
|
export type msgAwardData = [name: string, slotID: number, slotName: string, Ratio: number]
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// #region Interface
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// #region Enum
|
||
|
|
||
|
/** 頻道類型 */
|
||
|
export enum ChannelType {
|
||
|
Unknown,
|
||
|
|
||
|
/** 公頻 */
|
||
|
Public,
|
||
|
|
||
|
/** 私訊 */
|
||
|
Private,
|
||
|
|
||
|
/** 公會 */
|
||
|
Guild,
|
||
|
}
|
||
|
|
||
|
/** 訊息類型 */
|
||
|
export enum MsgType {
|
||
|
/** 純文字 */
|
||
|
Text = 1,
|
||
|
|
||
|
/** 圖片 */
|
||
|
Image,
|
||
|
|
||
|
/** 貼圖 */
|
||
|
Sticker,
|
||
|
|
||
|
/** 大獎推播 */
|
||
|
BigWinNotify,
|
||
|
|
||
|
/** 團體戰 */
|
||
|
TeamBattle = 101,
|
||
|
}
|
||
|
|
||
|
// #endregion
|