onCustomEvent() <- registering custom events
  onMapping() <-  custom mappings
  check out 'CustomMappingExample'

  more gifs has been added
  exceptions are more explicit
This commit is contained in:
JW
2023-12-11 23:18:40 +01:00
parent 46d5f15d3f
commit 3832db111e
28 changed files with 841 additions and 412 deletions

View File

@@ -26,6 +26,7 @@ import com.google.protobuf.ByteString;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
import io.github.jwdeveloper.tiktok.utils.ConsoleColors;
import io.github.jwdeveloper.tiktok.utils.JsonUtil;
import io.github.jwdeveloper.tiktok.utils.ProtocolUtils;
public class MessageUtil {
public static String getContent(WebcastResponse.Message message) {
@@ -50,39 +51,11 @@ public class MessageUtil {
return JsonUtil.messageToJson(deserialized);
} catch (Exception ex) {
var sb = new StringBuilder();
sb.append("Can not find mapper for " + methodName);
sb.append("Can not find protocolbuffer file message representation for " + methodName);
sb.append("\n");
try {
var files = com.google.protobuf.UnknownFieldSet.parseFrom(bytes);
for (var field : files.asMap().entrySet())
{
var value = field.getValue();
if(!value.getLengthDelimitedList().isEmpty())
{
sb.append(field.getKey()+" LengthDelimited "+value.getLengthDelimitedList()+" \n");
}
if(!value.getFixed32List().isEmpty())
{
sb.append(field.getKey()+" fixed32 "+value.getFixed32List()+" \n");
}
if(!value.getFixed64List().isEmpty())
{
sb.append(field.getKey()+" fixed64 "+value.getFixed64List()+" \n");
}
if(!value.getGroupList().isEmpty())
{
sb.append(field.getKey()+" group "+value.getGroupList()+" \n");
}
if(!value.getVarintList().isEmpty())
{
sb.append(field.getKey()+" varint "+value.getVarintList()+" \n");
}
}
} catch (Exception e) {
sb.append("Error while getting unknown fileds "+e.getMessage());
}
var structure = ProtocolUtils.getProtocolBufferStructure(bytes);
var json =structure.toJson();
sb.append(json);
//String jsonString = JsonFormat.printToString(protobufData);
return sb.toString();
}