Skip to content

About protocol buffer, and updating its structure

Jacek W edited this page Dec 11, 2023 · 2 revisions

TikTok sends events data in the protocolbuffer format so it's very important how does it works

Protocol Buffer documentation

All the protocolbuffer definitions and classes are location in the API module of project

TikTokLiveJava\API\src\main\proto at this path you can find all the .proto files that defines tiktok data structure. For example you can find there WebcastGift message that represends all gifts events that are coming from tiktok

//@GiftMessage
message WebcastGiftMessage {
  Common common = 1;
  int64 giftId = 2;
  int64 fanTicketCount = 3;
  int32 groupCount = 4;
  int32 repeatCount = 5;
  int32 comboCount = 6;
  User user = 7;
  User toUser = 8;
  int32 repeatEnd = 9;
  int64 groupId = 11;
  int64 incomeTaskgifts = 12;
  int64 roomFanTicketCount = 13;
  GiftStruct gift = 15;
  string logId = 16;
  int64 sendType = 17;
  string monitorExtra = 22;
  int64 colorId = 24;
  bool isFirstSent = 25;
  string orderId = 28;
  UserIdentity userIdentity = 32;

  message GiftIMPriority {
    repeated int64 queueSizesList = 1;
    int64 selfQueuePriority = 2;
    int64 priority = 3;
  }

  message PublicAreaCommon {
    Image userLabel = 1;
    int64 userConsumeInRoom = 2;
  }
}

API module in its pom.xml has maven plugin classedprotoc-jar-maven-plugin.

This plugin is looking from all the .proto files thats are at locationTikTokLiveJava\API\src\main\proto

Then generates from them Java classes to package io.github.jwdeveloper.tiktok.messages.data. Those classes are not visible in the IDE, but you can see them at location TikTokLiveJava\API\target\generated-sources\io\github\jwdeveloper\tiktok\messages

            <plugin>
                <groupId>com.github.os72</groupId>
                <artifactId>protoc-jar-maven-plugin</artifactId>
                <version>3.11.4</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <includeMavenTypes>direct</includeMavenTypes>
                            <inputDirectories>
                                <include>src/main/proto</include>
                            </inputDirectories>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

IMPORTANT TO RUN CLASS GENERATION USE Maven compile on the API module

image

Clone this wiki locally