-
-
Notifications
You must be signed in to change notification settings - Fork 43
About library
TikTokLive java was created because TikTok dose not provide offical API for lives. That means library itself will be never up to date with tiktok and might interprete some things differently
We can divide working of library to 4 important parts
-
Getting info about live from TikTok. Library is making 3 https requests
- first for getting live
Room_ID
- second for getting more specific live metadata such as live title, host name...
- third to
Sign API
that returns access token that is later use for connecting to TikTok websocket
- first for getting live
-
Connecting to TikTok websocket (PushServer)
After successful connection to TikTok,
pushServer
starts to sendProtocolBuffer
messages in binary format. This is very important to understandProtocolBuffer
. Don't worry it is not complicated :). All the proto files are included underAPI/src/main/proto
After usingMaven compile
command on project, java classes are generated from those files. so then we can easily map incoming bytes to classes, for examplesWebcastGiftMessage message = WebcastGiftMessage.parseFrom(incomingBytesArray)
-
Mapping TikTok data to events
At this point we have TikTok data inside protocol-buffer classes now we want to map it to events. Why? because
protocol-buffer classes
might be changed at any point, but we want to keep library code structure consistent across versions. so for exampleWebcastGiftMessage
is mapped toTikTokGiftEvent
-
trigger events
When the events objects are done last step is to trigger them. And that's it!
tikTokEventObserver.publish(liveClient, tiktokGiftEvent)