RPC call is not received by the server

Hi everyone,

I’ve played around with the Message Bus inspired by the McLarren demo from a while ago. Well I’ve used the GDC2016 plugin from Max from github as a starting point and got the client-server-discovery working quite quickly but then I got stuck at the RPC part.
So I initialize a RPC server on my server like this:



...
    RpcServer = FModuleManager::LoadModuleChecked<IMessagingRpcModule>("MessagingRpc").CreateRpcServer();
    RpcServer->RegisterHandler<FControllerCommand>(this, &AMessagingGameMode::HandleRequest);
...


The Handle Request looks like follows:



TAsyncResult<int32> AMessagingGameMode::HandleRequest(const FControllerCommandRequest& Message)
{
    UE_LOG(LogTemp, Warning, TEXT("Something arrived from the client"))
    switch (Message.Command)
    {
    case EControllerCommand::MoveForward:
        UE_LOG(LogTemp, Warning, TEXT("Got a forward message with %f"), Message.Value)
        break;
    case EControllerCommand::MoveRight:
        UE_LOG(LogTemp, Warning, TEXT("Got a right message with %f"), Message.Value)
        break;
    default:
        break;
    }
    return 0;
}


Furthermore my message declarations to be complete:



USTRUCT()
struct FControllerPing
{
    GENERATED_BODY()
};


USTRUCT()
struct FGamePong
{
    GENERATED_BODY()

    UPROPERTY(EditAnywhere, Category = "Message")
    FString GameAddress;

    FGamePong() { }
    FGamePong(const FString& InAddress)
        : GameAddress(InAddress)
    { }
};


UENUM()
enum class EControllerCommand : uint8
{
    MoveForward,
    MoveRight
};

USTRUCT()
struct FControllerCommandRequest : public FRpcMessage
{
    GENERATED_BODY()

    UPROPERTY(EditAnywhere, Category = "Message")
    EControllerCommand Command;

    UPROPERTY(EditAnywhere, Category = "Message")
    float Value;


    FControllerCommandRequest(EControllerCommand InCommand, float InValue)
        : Command(InCommand),
        Value(InValue)
    {
    }


    FControllerCommandRequest()
    {
    };
};

USTRUCT()
struct FControllerCommandResponse : public FRpcMessage
{
    GENERATED_BODY()

    UPROPERTY(EditAnywhere, Category = "Message")
    int32 Result;

    FControllerCommandResponse() : Result(INDEX_NONE)
    {
    }

    FControllerCommandResponse(int32 InResult) : Result(InResult)
    {
    }
};

DECLARE_RPC(FControllerCommand, int32)


The rpc client on the client side is created like this:



    RpcClient = FModuleManager::LoadModuleChecked<IMessagingRpcModule>("MessagingRpc").CreateRpcClient();

...
// later in the server address is extracted from the 'pong' message from the server

void AFFTControllerGameMode::HandleGamePongMessage(const FGamePong& Message,
                                                   const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
    FMessageAddress NewGameAddress;

    if (FMessageAddress::Parse(Message.GameAddress, NewGameAddress) && NewGameAddress != GameAddress)
    {
        GameAddress = NewGameAddress;
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red,
                                         FString::Printf(TEXT("Got new adresse %s"), *NewGameAddress.ToString()));
        RpcClient->Connect(NewGameAddress);
        OnGameFound.Broadcast();
    }

    LastGameResponse = FDateTime::UtcNow();
}




And finally an RPC call is issued like this:



void AFFTControllerGameMode::SendCommand(const EControllerCommand Command, const float Value) const
{
    if (Value == 0)
    {
        return;
    }

    if (RpcClient->IsConnected())
    {
        RpcClient->Call<FControllerCommand>(Command, Value);
    }
    else
    {
        UE_LOG(LogTemp, Error, TEXT("Command was not send because rpc client is not connected"))
    }
}


This function is just a simple abstraction.

On the surface everything is similar or the same as in the gdc2016 plugin. But the issued rpc requests don’t reach the server.
Does someone has an idea what I’m missing?

Hey conscienc3,
I’ve been struggling with the same problem. I found this slides http://www.slideshare.net/GerkeMaxPreussner/ue4-twitch-2016-0505-unreal-message-bus-overview
it seems that, based on the slides, this way of implemeting would only work if you wanted to send message to objects within the same process. In order to send messages to objects in different applications we need a “bridge”. I’ve found that the FUdpMessagingModule has that bridge implementation, but I’m not sure how to properly use everything together yet.

HI @talislincoln
thanks for your answer :slight_smile: Well that make sense. I remember in the mclerran thread Max mentioned that the UDP version is not production ready. A couple of days ago I managed to finish my use case with complete messaging. Which in my case works perfectly and I think its a better way since it imposes a certain programming model.
So you can replace the rpc in your case with messages.