ObjectDeliverer
v1.5.1
https://www.unrealengine.com/marketplace/ja/slug/objectdeliverer
ObjectDeliverer是Unreal Engine(C++,Blueprint)的資料傳輸/接收函式庫。
它具有以下特點。
master分支可使用UE5 5.0或更高版本建置; UE4 需要進行一些修改才能建置。
以下協議可與內建協定一起使用。您也可以新增自己的協定。
以下規則可用於內建的傳送和接收資料的分割規則。
固定尺寸
例)固定1024位元組的情況
標頭(內文尺寸)+內文
範例)當大小區域為 4 位元組時
按端子符號分割
範例)當 0x00 為結束時
void UMyClass::Start ()
{
auto deliverer = UObjectDelivererManager::CreateObjectDelivererManager ();
// bind connected event
deliverer-> Connected . AddDynamic ( this , &UMyClass::OnConnect);
// bind disconnected event
deliverer-> Disconnected . AddDynamic ( this , &UMyClass::OnDisConnect);
// bind receive event
deliverer-> ReceiveData . AddDynamic ( this , &UMyClass::OnReceive);
// start deliverer
// + protocol : TCP/IP Server
// + Data division rule : Header(BodySize) + Body
// + Serialization method : Byte Array
deliverer-> Start ( UProtocolFactory::CreateProtocolTcpIpServer ( 9099 ),
UPacketRuleFactory::CreatePacketRuleSizeBody ());
}
void UMyClass::OnConnect (UObjectDelivererProtocol* ClientSocket)
{
// send data
TArray<uint8> buffer;
deliverer-> Send (buffer);
}
void UMyClass::OnDisConnect (UObjectDelivererProtocol* ClientSocket)
{
// closed
UE_LOG (LogTemp, Log, TEXT ( " closed " ));
}
void UMyClass::OnReceive (UObjectDelivererProtocol* ClientSocket, const TArray<uint8>& Buffer)
{
// received data buffer
}
查看維基 https://github.com/ayumax/ObjectDeliverer/wiki