How can I define the port, protocol and endpoint the server is listening on? I need to handle messages that connect to Unreal Engine 4 via non Unreal Engine clients.
We currently have two transport plug-ins: UdpMessaging and TcpMessaging. They can be configured in the Project Settings under Plugins.
Can someone explane how to use UdpMessaging and TcpMessaging plugins?
I’m trying to make socket-connection between client and server. Can I use this plugins for it?
Or it’s work in Editor only?
Maybe some ways to use “Socket” part from it?
Hi, just wonder how to get the effect of running the app with command line “MessagingServer.exe -Messaging” if the server app is packaged in an IOS device.
I’m afraid I have no idea
I’d guess it could be enabled by a plugin (or some other option in project settings) by default, so it would also work for deployed apps on non-Windows (or non-PC for that matter).
There might be C++ methods (or even Blueprint nodes at this point?) to do it programmatically; but again, I haven’t looked too much into it at this point.
Hey, sorry for the delayed response - I’ve been super busy and don’t check the forums often. I’m afraid that I don’t fully understand your question. Which UI are you referring to?
Hi, One Question.
Your basic codes are good for me and I wonder how to receive data in USTRUCT.
Here is my main code in 4.20.
ClientComponent.h
USTRUCT(BlueprintType)
struct FJumpNowMessage
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Type")
int32 **OrderIndex**;
};
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MMOTESTPROJECT_API UClientComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UClientComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
// Called when the game ends
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
private:
TSharedPtr<FMessageEndpoint, ESPMode::ThreadSafe> JumpEndpoint;
public:
// blueprints should call this function to trigger a remote jump
UFUNCTION(BlueprintCallable, Category = "Remote Jump")
void TriggerJump();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Remote Jump")
FJumpNowMessage **myMessage**;
};
And my ClientComponent.cpp, I set my USTRUCT “myMessage” value in Blueprint.
...................
...................
void UClientComponent::TriggerJump()
{
if (JumpEndpoint.IsValid()){
JumpEndpoint->Publish<FJumpNowMessage>(new FJumpNowMessage(**myMessage**));
}
}
And ServerComponent.h
USTRUCT(BlueprintType)
struct FJumpNowMessage
{
GENERATED_USTRUCT_BODY()
UPROPERTY(BlueprintReadOnly, Category = "Type")
int32 OrderIndex;
};
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class TPC_420_API UServerComponent : public UActorComponent
{
GENERATED_BODY()
public:
UServerComponent();
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
private:
TSharedPtr<FMessageEndpoint, ESPMode::ThreadSafe>JumpEndpoint;
void JumpNowHandler(const struct FJumpNowMessage& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context);
public:
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FJumpNowSignature);
UPROPERTY(BlueprintAssignable)
FJumpNowSignature OnJumpNow;
UPROPERTY(BlueprintReadOnly, Category = "Remote Jump")
FJumpNowMessage myMessage;
};
ServerComponent.cpp
UServerComponent::UServerComponent() {
}
// Called when the game starts
void UServerComponent::BeginPlay()
{
Super::BeginPlay();
JumpEndpoint = FMessageEndpoint::Builder("UServerComponent").Handling<FJumpNowMessage>(this, &UServerComponent::JumpNowHandler);
if (JumpEndpoint.IsValid())
JumpEndpoint->Subscribe<FJumpNowMessage>();
}
// Called when the game ends
void UServerComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
JumpEndpoint.Reset();
Super::EndPlay(EndPlayReason);
}
void UServerComponent::JumpNowHandler(const FJumpNowMessage& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
OnJumpNow.Broadcast();
}
How can I get Values of USTRUCT from Client in my ServerComponet?
I believe you’re looking at this differently, and I’m not sure if this works like that. That message is meant to carry the data (like a letter being put into an envelope), not to be part of a component (like carrying the post-box as a backpack just in case you find some envelopes along the way).
Try thinking of them a different things - the struct is only meant to be sent between server and client; but they have nothing to do with the actual component. You do get the values in the component, just look at the message being received:
Client:
auto* myMessage = new FJumpNowMessage;
myMessage->OrderIndex = 42;
JumpEndpoint->Publish<FJumpNowMessage>(myMessage);
Server:
void UServerComponent::JumpNowHandler(const FJumpNowMessage& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
Int32 TheClientsOrderIndex = Message.OrderIndex;
// use TheClientsOrderIndex as you see fit
}
You may declare members on your Client/Server Component and set them from Blueprint for example, but they should be simple properties such as Int32 (and not of the structure type).
(It might work that way, but I’d recommend not doing it, since you’re mixing two things - your components and their communication)
HTH.
hi. i mean how do you do the swipe on the tablet. Is it on the slate/widget? gmpreussner
Saw a slide on a presentation on this mention named pipes, is there a transport for that in engine or is it still TCP/UDP only?
Still TCP and UDP only. I never found the time to write other transports.
Hi,
I’m currently playing around with the messaging system and am trying to get this example running in ue4 4.22.3 … but I’m stuck right in the beginning when getting two separate ue4 games to connect to each other. I’m starting my server with ‘mappath?listen -server -messaging’ and the client with ‘ip -game -messaging’ … but they don’t want to connect because I can’t see my debug log messages … does someone have an idea? Btw. the messaging system is intended to be used to let two different ue4 games communicate between each other right?
Hello,
so I am looking into the possibilites of message bus too.
I’ve got a basic example running. Everything is fine as long as I package my game with a development build configuration. As soon as I switch to a shipping build configuration my setup breaks.
Using shipping builds I can not even see any messages in the Messaging Debugger Window.
I assume messaging and UDP are disabled in shipping builds?
I tried to add “Messaging” and “UdpMessaging” in my Build.cs PrivateDependencyModuleNames line, but that didn’t do the trick. I also tried adding slate, although not using it. No success.
I am stuck.
Is it possible to use the message bus in shipping builds? What would be the propper way to set up packaging?
Thank you very much.
@conscienc3
Are you sure you need all that network multiplayer stuff? Cause if it is only for message bus, you only need that one option “-Messaging” but on both of your instances.
So, any news about messaging? Does it seem like messaging.h deprecated? Does any relevant sample exist?
Sorry for the delayed response, this fell through the cracks…
This is correct. The message bus is not secure for use in production, so it is disabled by default. You’ll have to edit engine code to bypass that, but I recommend that you only use the feature for development.
Messaging.h has been deprecated a long time, just like all other monolithic header files in the engine. You need to include the individual headers that you actually use now, i.e. IMessageBus.h
Hi @gmpreussner,
may I ask how your setup for the McLarren Demo was? That means then that the build you ran during the exhibition were development builds. Am I right? Are there plans from epic to enable the message bus via network for production builds?
conscienc3 and I discussed this offline in Discord. For everybody else: The message transport plug-ins are currently disabled, because their implementations are still prototypical and have no security mechanisms. This represents a security hazard for production applications (a network port would be open, and everybody can send packets to it, possibly crashing the application or perform stack overflow based attacks).
At Epic I never found the time to implement more robust transport plug-ins, but I’m planning to write some later this year. They won’t be free, however.