关于protobuf:抖音直播protobuf

79次阅读

共计 2781 个字符,预计需要花费 7 分钟才能阅读完成。

protobuf 之前有说过,就不再反复了。可回顾《万方 protobuf 协定申请案例》。

原文链接:https://blog.csdn.net/weixin_…

查看 common-utils-message.979d96f7.js 中的办法

var d = (new Map).
 set("WebcastDiggMessage", "DiggMessage").
 set("WebcastFansclubMessage", "FansclubMessage").
 set("WebcastScreenChatMessage", "ScreenChatMessage").
 set("WebcastControlMessage", "ControlMessage").
 set("WebcastSocialMessage", "SocialMessage").
 set("WebcastRoomMessage", "RoomMessage").
 set("WebcastFansclubStatisticsMessage", "FansclubStatisticsMessage"
 set("WebcastRoomVerifyMessage", "RoomVerifyMessage").
 set("WebcastNoticeMessage", "NoticeMessage").
 set("WebcastNobleUpgradeMessage", "NobleUpgradeMessage").
 set("WebcastImDeleteMessage", "ImDeleteMessage").
 set("WebcastSunDailyRegionRankMessage","SunDailyRankMessage").
 set("WebcastSunDailyRankMessage", "SunDailyRankMessage").
 set("WebcastRoomUserSeqMessage", "RoomUserSeqMessage").
 set("WebcastVerificationCodeMessage", "VerificationCodeMessage").
 set("WebcastLinkMicMethod", "LinkMicMethod").
 set("WebcastLinkMicBattleMethod", "LinkMicBattle")
 .set("WebcastLinkMicBattleFinishMethod", "LinkMicBattleFinish").
 set("WebcastRoomNotifyMessage", "NotifyMessage").
 set("WebcastLinkMicSignalingMethod", "LinkMicSignalingMethod").
 set("WebcastLotteryEventMessage", "LotteryEventMessage").
 set("WebcastUploadCoverMessage", "UploadCoverMessage").
 set("WebcastCategoryChangeMessage", "CategoryChangeMessage").
 set("WebcastRoomChallengeMessage", "RoomChallengeMessage").
 set("WebcastLikeMessage", "LikeMessage").
 set("WebcastLinkMicArmiesMethod", "LinkMicArmies").
 set("WebcastGameInviteMessage", "GameInviteMessage").
 set("WebcastQuizStartMessage", "QuizStartMessage").
 set("WebcastQuizResultMessage", "QuizResultMessage").
 set("WebcastQuizChangeMessage", "QuizChangeMessage").
 set("WebcastQuizBeginMessage", "QuizBeginMessage").
 set("WebcastOChannelAnchorMessage", "OChannelAnchorMessage").
 set("WebcastOChannelModifyMessage", "OChannelModifyMessage").
 set("WebcastLinkMicOChannelKickOutMsg", "LinkMicOChannelKickOutMsg").
 set("WebcastLinkMicOChannelNotifyMsg", "LinkMicOChannelNotifyMsg").
 set("WebcastRoomIntroMessage", "RoomIntroMessage").
 set("WebcastGroupShowUserUpdateMessage", "GroupShowUserUpdateMessage");

依据 Js 中的代码,定义 proto 文件

定义.proto 文件很简略:为要序列化的每个数据结构增加条 message,而后为 message 中的每个字段指

则 proto 文件内容如下

message ChatMessage{
  Common common = 1;
  User user = 2;
  string content = 3;
  bool visibleToSender = 4;
  Image backgroundImage = 5;
  string fullScreenTextColor = 6;
  Image backgroundImageV2 = 7;
  PublicAreaCommon publicAreaCommon = 9;
  Image giftImage = 10;
}

再比方这个 GiftMessage

则 proto 文件内容如下

message GiftMessage{
    repeated Common common=1;
    uint64 giftId=2;
    uint64 fanTicketCount=3;
    uint64 groupCount=4;
    uint64 repeatCount=5;
    uint64 comboCount=6;
    repeated User user=7;
    repeated User toUser=8;
    int32 repeatEnd = 9;
    TextEffect textEffect = 10;
    int64 groupId = 11;
    int64 incomeTaskgifts = 12;
    int64 roomFanTicketCount = 13;
}

python 调用、源码下载 请查看原文:
https://blog.csdn.net/weixin_…

正文完
 0