From b663f477135098e37e7f22fb0471b6bb8e7f835f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 29 Sep 2024 20:10:14 +0800 Subject: [PATCH] style: ScalarType --- src/core/proto/Message.ts | 26 +++++++++++++----------- src/core/proto/ProfileLike.ts | 38 +++++++++++++++++------------------ 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/core/proto/Message.ts b/src/core/proto/Message.ts index 5999e9a1..02a52afe 100644 --- a/src/core/proto/Message.ts +++ b/src/core/proto/Message.ts @@ -1,13 +1,13 @@ -import { MessageType, BinaryReader } from '@protobuf-ts/runtime'; +import { MessageType, BinaryReader, ScalarType } from '@protobuf-ts/runtime'; export const BodyInner = new MessageType("BodyInner", [ - { no: 1, name: "msgType", kind: "scalar", T: 13 /* uint32 */, opt: true }, - { no: 2, name: "subType", kind: "scalar", T: 13 /* uint32 */, opt: true } + { no: 1, name: "msgType", kind: "scalar", T: ScalarType.UINT32 /* uint32 */, opt: true }, + { no: 2, name: "subType", kind: "scalar", T: ScalarType.UINT32 /* uint32 */, opt: true } ]); export const NoifyData = new MessageType("NoifyData", [ - { no: 1, name: "skip", kind: "scalar", T: 12 /* bytes */, opt: true }, - { no: 2, name: "innerData", kind: "scalar", T: 12 /* bytes */, opt: true } + { no: 1, name: "skip", kind: "scalar", T: ScalarType.BYTES /* bytes */, opt: true }, + { no: 2, name: "innerData", kind: "scalar", T: ScalarType.BYTES /* bytes */, opt: true } ]); export const MsgHead = new MessageType("MsgHead", [ @@ -20,26 +20,28 @@ export const Message = new MessageType("Message", [ ]); export const SubDetail = new MessageType("SubDetail", [ - { no: 1, name: "msgSeq", kind: "scalar", T: 13 /* uint32 */ }, - { no: 2, name: "msgTime", kind: "scalar", T: 13 /* uint32 */ }, - { no: 6, name: "senderUid", kind: "scalar", T: 9 /* string */ } + { no: 1, name: "msgSeq", kind: "scalar", T: ScalarType.UINT32 /* uint32 */ }, + { no: 2, name: "msgTime", kind: "scalar", T: ScalarType.UINT32 /* uint32 */ }, + { no: 6, name: "senderUid", kind: "scalar", T: ScalarType.STRING /* string */ } ]); export const RecallDetails = new MessageType("RecallDetails", [ - { no: 1, name: "operatorUid", kind: "scalar", T: 9 /* string */ }, + { no: 1, name: "operatorUid", kind: "scalar", T: ScalarType.STRING /* string */ }, { no: 3, name: "subDetail", kind: "message", T: () => SubDetail } ]); export const RecallGroup = new MessageType("RecallGroup", [ - { no: 1, name: "type", kind: "scalar", T: 5 /* int32 */ }, - { no: 4, name: "peerUid", kind: "scalar", T: 13 /* uint32 */ }, + { no: 1, name: "type", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, + { no: 4, name: "peerUid", kind: "scalar", T: ScalarType.UINT32 /* uint32 */ }, { no: 11, name: "recallDetails", kind: "message", T: () => RecallDetails }, - { no: 37, name: "grayTipsSeq", kind: "scalar", T: 13 /* uint32 */ } + { no: 37, name: "grayTipsSeq", kind: "scalar", T: ScalarType.UINT32 /* uint32 */ } ]); + export function decodeMessage(buffer: Uint8Array): any { const reader = new BinaryReader(buffer); return Message.internalBinaryRead(reader, reader.len, { readUnknownField: true, readerFactory: () => new BinaryReader(buffer) }); } + export function decodeRecallGroup(buffer: Uint8Array): any { const reader = new BinaryReader(buffer); return RecallGroup.internalBinaryRead(reader, reader.len, { readUnknownField: true, readerFactory: () => new BinaryReader(buffer) }); diff --git a/src/core/proto/ProfileLike.ts b/src/core/proto/ProfileLike.ts index a5792a33..662f6ceb 100644 --- a/src/core/proto/ProfileLike.ts +++ b/src/core/proto/ProfileLike.ts @@ -1,14 +1,14 @@ -import { MessageType, BinaryReader, RepeatType } from '@protobuf-ts/runtime'; +import { MessageType, BinaryReader, ScalarType, RepeatType } from '@protobuf-ts/runtime'; export const LikeDetailType = new MessageType("LikeDetailType", [ - { no: 1, name: "txt", kind: "scalar", T: 9 /* string */ }, - { no: 2, name: "uin", kind: "scalar", T: 3 /* int64 */ }, - { no: 3, name: "nickname", kind: "scalar", T: 9 /* string */ } + { no: 1, name: "txt", kind: "scalar", T: ScalarType.STRING /* string */ }, + { no: 2, name: "uin", kind: "scalar", T: ScalarType.INT64 /* int64 */ }, + { no: 3, name: "nickname", kind: "scalar", T: ScalarType.STRING /* string */ } ]); export const LikeMsgType = new MessageType("LikeMsgType", [ - { no: 1, name: "times", kind: "scalar", T: 5 /* int32 */ }, - { no: 2, name: "time", kind: "scalar", T: 5 /* int32 */ }, + { no: 1, name: "times", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, + { no: 2, name: "time", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, { no: 3, name: "detail", kind: "message", T: () => LikeDetailType } ]); @@ -17,29 +17,29 @@ export const ProfileLikeSubTipType = new MessageType("ProfileLikeSubTipType", [ ]); export const ProfileLikeTipType = new MessageType("ProfileLikeTipType", [ - { no: 1, name: "msgType", kind: "scalar", T: 5 /* int32 */ }, - { no: 2, name: "subType", kind: "scalar", T: 5 /* int32 */ }, + { no: 1, name: "msgType", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, + { no: 2, name: "subType", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, { no: 3, name: "content", kind: "message", T: () => ProfileLikeSubTipType } ]); export const SysMessageHeaderType = new MessageType("SysMessageHeaderType", [ - { no: 1, name: "id", kind: "scalar", T: 9 /* string */ }, - { no: 2, name: "timestamp", kind: "scalar", T: 5 /* int32 */ }, - { no: 3, name: "sender", kind: "scalar", T: 9 /* string */ } + { no: 1, name: "id", kind: "scalar", T: ScalarType.STRING /* string */ }, + { no: 2, name: "timestamp", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, + { no: 3, name: "sender", kind: "scalar", T: ScalarType.STRING /* string */ } ]); export const SysMessageMsgSpecType = new MessageType("SysMessageMsgSpecType", [ - { no: 1, name: "msgType", kind: "scalar", T: 5 /* int32 */ }, - { no: 2, name: "subType", kind: "scalar", T: 5 /* int32 */ }, - { no: 3, name: "subSubType", kind: "scalar", T: 5 /* int32 */ }, - { no: 4, name: "msgSeq", kind: "scalar", T: 5 /* int32 */ }, - { no: 5, name: "time", kind: "scalar", T: 5 /* int32 */ }, - { no: 6, name: "msgId", kind: "scalar", T: 3 /* int64 */ }, - { no: 7, name: "other", kind: "scalar", T: 5 /* int32 */ } + { no: 1, name: "msgType", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, + { no: 2, name: "subType", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, + { no: 3, name: "subSubType", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, + { no: 4, name: "msgSeq", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, + { no: 5, name: "time", kind: "scalar", T: ScalarType.INT32 /* int32 */ }, + { no: 6, name: "msgId", kind: "scalar", T: ScalarType.INT64 /* int64 */ }, + { no: 7, name: "other", kind: "scalar", T: ScalarType.INT32 /* int32 */ } ]); export const SysMessageBodyWrapperType = new MessageType("SysMessageBodyWrapperType", [ - { no: 1, name: "wrappedBody", kind: "scalar", T: 12 /* bytes */ } + { no: 1, name: "wrappedBody", kind: "scalar", T: ScalarType.BYTES /* bytes */ } ]); export const SysMessageType = new MessageType("SysMessageType", [