Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

UE4 Twitch 2016 05-05: Unreal Message Bus Overview

1,371 views

Published on

These slides accompanied the Unreal Engine 4 Twitch stream on May 5th, 2016, which explained how the GDC 2016 McLarren demo was built.

Published in: Software
  • Be the first to comment

UE4 Twitch 2016 05-05: Unreal Message Bus Overview

  1. 1. UE4 Twitch Stream 5/5/2016 Unreal Message Bus Overview Gerke Max Preussner max.preussner@epicgames.com @gmpreussner
  2. 2. Process Message Endpoints Message Bus Message Bus: Framework for exchanging commands, events, documents, or any other data inside UStructs between endpoints USTRUCT() struct FHelloMessage { GENERATED_BODY() UPROPERTY(EditAnywhere, Category=“Message”) FString HelloText; FHelloMessage(const FString& InText) : HelloText(InText) { } }; Declare a message type (you can also use any existing UStruct, such as FVector or FColor)
  3. 3. Process SenderEndpoint = FMessageEndpoint::Builder(“FMySender”, MessageBus); ReceiverEndpoint = FMessageEndpoint::Builder(“FMyReceiver”, MessageBus) .Handling<FHelloMessage>(this, &FMyReceiver::HandleHelloMessage); Create a sender endpoint Create a receiver endpoint Message Endpoints: Helper classes for sending and receiving messages on the message bus
  4. 4. Process Subscribers Publisher SenderEndpoint = FMessageEndpoint::Builder(“FMySender”, MessageBus); ReceiverEndpoint = FMessageEndpoint::Builder(“FMyReceiver”, MessageBus) .Handling<FHelloMessage>(this, &FMyReceiver::HandleHelloMessage); if (ReceiverEndpoint.IsValid()) { ReceiverEndpoint->Subscribe<FHelloMessage>(); } SenderEndpoint.Publish(new FHelloMessage(TEXT(“Hey there!”))); void FMyReceiver::HandleHelloMessage(const FHelloMessage& Message, const TSharedRef<IMessageContextRef>& Context) { GLog->Log(*Message.HelloText); // prints “Hey there!” } Subscribe receiver to FHelloMessage messages Publish a message to all subscribers Handle received FHelloMessage Publish-Subscribe: Messages are sent to all endpoints that subscribed to that message type
  5. 5. Process Responder Requester SenderEndpoint = FMessageEndpoint::Builder(“FMySender”, MessageBus); ReceiverEndpoint = FMessageEndpoint::Builder(“FMyReceiver”, MessageBus) .Handling<FHelloMessage>(this, &FMyReceiver::HandleHelloMessage); if (ReceiverEndpoint.IsValid()) { ReeiverEndpoint->Subscribe<FHelloMessage>(); } SenderEndpoint.Publish(new FHelloMessage(TEXT(“Hey there!”))); void FMyReceiver::HandleHelloMessage(const FHelloMessage& Message, const TSharedRef<IMessageContextRef>& Context) { SenderEndpoint->Send(new FReplyMessage(TEXT(“O hai!”)), Context->GetSender()); } Send back a response Request-Response: Messages are sent directly to one or more recipients using their message address
  6. 6. Process Process Message Bridge Message Bridges: Connect two message buses in separate processes via some transport technology
  7. 7. Process Process UDP TCP HTTP Named Pipes Shared Mem ZeroMQ RabbitMQ etc. Message Bridges: Connect two message buses in separate processes via some transport technology
  8. 8. Computer Computer Computer Process Process Process Process Internet (via Message Tunnel) UE4 Instance 3DStudio Max Maya Build Farm Hardware I/O etc.
  9. 9. The following slides explain UE4’s layered architecture for device management as a more complex example use case for how the Messaging system can be used to simplify the process of writing distributed applications. The diagrams show how the same code architecture is being used to support a number of different hardware configurations. The last slide shows how the function calls flow through the various layers. Note that some of this code has changed over the course of the last year. The intent is to demonstrate how interprocess communication can be implemented, and how function calls change to messages and back to function calls.
  10. 10. UserPCHostPC ITargetDevice ITargetDeviceService ITargetDeviceProxy Device Application Platform specific interfaces Platform agnostic interfaces Physical Tier Legend: Target Device Management Uses a multi-layered multi-tier architecture instead of having the application talk directly to the devices MessageBus Platform SDK
  11. 11. Device Daemon UserPCHostPC ITargetDevice ITargetDeviceService ITargetDeviceProxy MessageBus IPP Application Message Bus UserPCHostPC ITargetDevice ITargetDeviceService ITargetDeviceProxy Device Application Platform specific interfaces Platform agnostic interfaces Physical Tier Legend: • Target devices are usually connected to some host computer and communicate via some platform SDK Example: XBoxOne, PS4 • Some target devices can be deployed to without a host computer if they have a network connection Example: Windows, Mac, iPad, iPhone MessageBus Platform SDK
  12. 12. User/HostPC ITargetDevice ITargetDeviceService ITargetDeviceProxy Device MessageBus Platform SDK Application UserPCHostPC/Device ITargetDevice ITargetDeviceService ITargetDeviceProxy MessageBus Application UserPC/HostPC/Device ITargetDevice ITargetDeviceService ITargetDeviceProxy MessageBus Application UserPCHostPC ITargetDevice ITargetDeviceService ITargetDeviceProxy Device MessageBus Platform SDK Application • Target device is another computer Example: Deploying to another PC • Target device is the local computer Example: Deploying to your own PC • Target device is another device connected to the local PC Example: iPhone, iPad on your own computer • Target device is another device connected to another PC Example: iPhone, iPad on someone else’s computer
  13. 13. Application ILauncher Launch() FLauncherWorker Run() ITargetDeviceProxy PerformTask() FLauncherDeployToDeviceTask DeployApp(TransactionId) ITargetDeviceService targetdevice.deploy.file targetdevice.deploy.commit ITargetDevice Local File Cache Deploy(Directory) IPP iOS Device Copy Files Deploy Files targetdevice.deploy.finished (AppId) OnDeployCommitted(TransactionId, AppId) Deploy Launch FLauncherLaunchTask PerformTask() LaunchApp(AppId) targetdevice.launch Launch(AppId) Launch Daemon iosdaemon.launch [Url] iosdaemon.launch .success targetdevice.launch.finished return AppId Device File System Message Bus Function Call Vendor Specific Legend:

×