测试复杂消息
This commit is contained in:
Binary file not shown.
@@ -11,6 +11,8 @@
|
|||||||
#include "TurboLinkGrpcUtilities.h"
|
#include "TurboLinkGrpcUtilities.h"
|
||||||
#include "TurboLinkGrpcConfig.h"
|
#include "TurboLinkGrpcConfig.h"
|
||||||
|
|
||||||
|
#include "SUser/UserMessage.h"
|
||||||
|
|
||||||
void UTimeTestWidget::NativeConstruct()
|
void UTimeTestWidget::NativeConstruct()
|
||||||
{
|
{
|
||||||
Super::NativeConstruct();
|
Super::NativeConstruct();
|
||||||
|
|||||||
@@ -19,3 +19,71 @@ void UTurboLinkTestGameInstance::Shutdown()
|
|||||||
TurboLinkManager->Shutdown();
|
TurboLinkManager->Shutdown();
|
||||||
TurboLinkManager = nullptr;
|
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 "CoreMinimal.h"
|
||||||
#include "Engine/GameInstance.h"
|
#include "Engine/GameInstance.h"
|
||||||
|
#include "SUser/UserMessage.h"
|
||||||
#include "TurboLinkTestGameInstance.generated.h"
|
#include "TurboLinkTestGameInstance.generated.h"
|
||||||
|
|
||||||
class UTurboLinkGrpcManager;
|
class UTurboLinkGrpcManager;
|
||||||
@@ -19,6 +20,16 @@ public:
|
|||||||
void Init() override;
|
void Init() override;
|
||||||
void Shutdown() 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:
|
protected:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
UTurboLinkGrpcManager* TurboLinkManager;
|
UTurboLinkGrpcManager* TurboLinkManager;
|
||||||
|
|||||||
+16
-2
@@ -7,8 +7,22 @@ import "common.proto";
|
|||||||
|
|
||||||
message RegisterRequest {
|
message RegisterRequest {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
Common.Gender gender = 2;
|
bytes bytes_value=2;
|
||||||
repeated Address address = 3;
|
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 {
|
message Address {
|
||||||
string address = 1;
|
string address = 1;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
User "tldemo/services/User"
|
User "tldemo/services/User"
|
||||||
Common "tldemo/services/Common"
|
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})
|
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)
|
s.UserArray = append(s.UserArray, userData)
|
||||||
|
|
||||||
replyMessage := fmt.Sprintf("Hello %s, Your Id is %v", userData.Name, userData.Id)
|
replyMessage := fmt.Sprintf("Hello %s, Your Id is %v", userData.Name, userData.Id)
|
||||||
|
|||||||
Reference in New Issue
Block a user