测试复杂消息
This commit is contained in:
Binary file not shown.
@@ -11,6 +11,8 @@
|
||||
#include "TurboLinkGrpcUtilities.h"
|
||||
#include "TurboLinkGrpcConfig.h"
|
||||
|
||||
#include "SUser/UserMessage.h"
|
||||
|
||||
void UTimeTestWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
@@ -19,3 +19,71 @@ void UTurboLinkTestGameInstance::Shutdown()
|
||||
TurboLinkManager->Shutdown();
|
||||
TurboLinkManager = nullptr;
|
||||
}
|
||||
|
||||
FString UTurboLinkTestGameInstance::DumpBytes(const FBytes& Bytes)
|
||||
{
|
||||
FString ret;
|
||||
for (uint8 value : Bytes.Value)
|
||||
{
|
||||
char temp[8] = { 0 };
|
||||
ret += FString::Printf(TEXT("%02X "), value);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void UTurboLinkTestGameInstance::DumpMapMessage(const TMap<FInt64, FGrpcUserRegisterRequestAddress>& Message)
|
||||
{
|
||||
FString temp = "";
|
||||
for (const auto& item : Message)
|
||||
{
|
||||
temp += FString::Printf(TEXT("%s:[%s,%s],"), *UTurboLinkGrpcUtilities::CastInt64ToString(item.Key), *item.Value.Address, *item.Value.PostalCode);
|
||||
}
|
||||
UE_LOG(LogTemp, Warning, TEXT("ExtAddress={%s}"), *temp);
|
||||
}
|
||||
|
||||
void UTurboLinkTestGameInstance::DumpMessage(const FGrpcUserRegisterRequest& Message)
|
||||
{
|
||||
/*
|
||||
UE_LOG(LogTemp, Warning, TEXT("----------------- Dump Begin -----------------"));
|
||||
UE_LOG(LogTemp, Warning, TEXT("Name=%s"), *Message.Name);
|
||||
UE_LOG(LogTemp, Warning, TEXT("BytesValue=%s"), *DumpBytes(Message.BytesValue));
|
||||
UE_LOG(LogTemp, Warning, TEXT("Gender=%s"), *UEnum::GetValueAsString<EGrpcCommonGender>(Message.Gender));
|
||||
UE_LOG(LogTemp, Warning, TEXT("MessageValue={add:%s, postcode:%s}"), *Message.MessageValue.Address, *Message.MessageValue.PostalCode);
|
||||
UE_LOG(LogTemp, Warning, TEXT("IntValue=%d"), Message.IntValue);
|
||||
|
||||
FString temp;
|
||||
for (const auto& item : Message.ExtDict)
|
||||
{
|
||||
temp += FString::Printf(TEXT("%d:%s,"), item.Key, *item.Value);
|
||||
}
|
||||
UE_LOG(LogTemp, Warning, TEXT("ExtDict={%s}"), *temp);
|
||||
|
||||
temp = "";
|
||||
for (const auto& item : Message.ExtBytes)
|
||||
{
|
||||
temp += FString::Printf(TEXT("%s:[%s],"), *item.Key, *DumpBytes(item.Value));
|
||||
}
|
||||
UE_LOG(LogTemp, Warning, TEXT("ExtBytes={%s}"), *temp);
|
||||
|
||||
temp = "";
|
||||
for (const auto& item : Message.ExtEnum)
|
||||
{
|
||||
temp += FString::Printf(TEXT("%s:%s,"), *UTurboLinkGrpcUtilities::CastUInt64ToString(item.Key), *UEnum::GetValueAsString<EGrpcCommonGender>(item.Value));
|
||||
}
|
||||
UE_LOG(LogTemp, Warning, TEXT("ExtEnum={%s}"), *temp);
|
||||
|
||||
temp = "";
|
||||
for (const auto& item : Message.ExtAddress)
|
||||
{
|
||||
temp += FString::Printf(TEXT("%s:[%s,%s],"), *UTurboLinkGrpcUtilities::CastInt64ToString(item.Key), *item.Value.Address, *item.Value.PostalCode);
|
||||
}
|
||||
UE_LOG(LogTemp, Warning, TEXT("ExtAddress={%s}"), *temp);
|
||||
|
||||
temp = "";
|
||||
for (const auto& item : Message.ExtInt)
|
||||
{
|
||||
temp += FString::Printf(TEXT("%d:%d,"), item.Key, item.Value);
|
||||
}
|
||||
UE_LOG(LogTemp, Warning, TEXT("ExtInt={%s}"), *temp);
|
||||
*/
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "SUser/UserMessage.h"
|
||||
#include "TurboLinkTestGameInstance.generated.h"
|
||||
|
||||
class UTurboLinkGrpcManager;
|
||||
@@ -19,6 +20,16 @@ public:
|
||||
void Init() override;
|
||||
void Shutdown() override;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DumpMessage(const FGrpcUserRegisterRequest& Message);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DumpMapMessage(const TMap<FInt64, FGrpcUserRegisterRequestAddress>& Message);
|
||||
|
||||
protected:
|
||||
FString DumpBytes(const FBytes& Bytes);
|
||||
|
||||
protected:
|
||||
UPROPERTY()
|
||||
UTurboLinkGrpcManager* TurboLinkManager;
|
||||
|
||||
+16
-2
@@ -7,8 +7,22 @@ import "common.proto";
|
||||
|
||||
message RegisterRequest {
|
||||
string name = 1;
|
||||
Common.Gender gender = 2;
|
||||
repeated Address address = 3;
|
||||
bytes bytes_value=2;
|
||||
Common.Gender gender = 3;
|
||||
Address message_value = 4;
|
||||
int32 int_value = 5;
|
||||
|
||||
repeated string names_field = 6;
|
||||
repeated bytes bytes_field = 7;
|
||||
repeated Common.Gender enum_field = 8;
|
||||
repeated Address address = 9;
|
||||
repeated int64 test_array = 10;
|
||||
|
||||
map<int32, string> ext_dict = 11;
|
||||
map<string, bytes> ext_bytes = 12;
|
||||
map<int32, Common.Gender> ext_enum = 13;
|
||||
map<string, Address> ext_address = 14;
|
||||
map<string, int64> ext_int = 15;
|
||||
|
||||
message Address {
|
||||
string address = 1;
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"errors"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"encoding/json"
|
||||
|
||||
User "tldemo/services/User"
|
||||
Common "tldemo/services/Common"
|
||||
)
|
||||
@@ -35,6 +37,11 @@ func (s *UserServer) Register(ctx context.Context, in *User.RegisterRequest) (*C
|
||||
userData.Addresses = append(userData.Addresses, &UserAddress{Address : in.Address[i].Address, PostalCode: in.Address[i].PostalCode})
|
||||
}
|
||||
|
||||
log.Printf("----------------- Dump Begin -----------------")
|
||||
jsonBytes, _ := json.MarshalIndent(in, "", " ")
|
||||
log.Printf("%s", string(jsonBytes))
|
||||
|
||||
|
||||
s.UserArray = append(s.UserArray, userData)
|
||||
|
||||
replyMessage := fmt.Sprintf("Hello %s, Your Id is %v", userData.Name, userData.Id)
|
||||
|
||||
Reference in New Issue
Block a user