Core Concepts

USTRUCTs

USTRUCTs are compile-time groups of variables that can be made visible to the Unreal reflection system as UPROPERTIES. WebSock uses them to enforce type-safety when sending and receiving arbitrary websocket payloads.


UPROPERTY

A UPROPERTY can be serialised, decorated with metadata and used with the Unreal Editor and/or Blueprints.

// lone UPROPERTY
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
int32 Bar; 

// UPROPERTY contained within a USTRUCT
USTRUCT(BlueprintType)
struct Foo 
{
    GENERATED_BODY()  
      
    UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
    int32 Baz; 
}

These powerful building blocks form the foundation of modular, data-driven-design inside the Unreal Engine.


Interaction with WebSock

As mentioned, USTRUCTs are data structures that help you organise and manipulate related properties. WebSock is built to exploit this by providing type-safe serialisation and transport via USTRUCTs.

Example payload

USTRUCT(BlueprintType)
struct FExamplePayload 
{
    GENERATED_BODY()   
     
    UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
    FString bar; 
}

Using WebSock any USTRUCT in Unreal Engine can be automagically transformed into a JSON payload suitable for network interop with external services. This avoids the risky, manual toil of writing custom BP exposed (de)serialisation code for each USTRUCT individually.

Blueprint

Any Blueprint exposed USTRUCT can take advantage of WebSock's powerful polymorphic serialisation via ToJSON and FromJSON that takes any (wildcard) struct input and returns an FString payload.

Previous
Getting started
© Hench Technology Ltd