2
\$\begingroup\$

I'm trying to implement PhotonPeer in Unreal Engine 4.8 but I'm stuck at the connect function. I need to provide an AppId, but nothing I try is accepted by UE4.

Here's my code:

DALGameInstance.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Engine/GameInstance.h"
#ifdef __clang__
#pragma clang diagnostic ignored "-Woverloaded-virtual"
#endif
#if _EG_WINDOWS_PLATFORM
#include "AllowWindowsPlatformTypes.h"
#endif
#pragma warning (disable: 4263)
#pragma warning (disable: 4264)
#include "Photon/Photon-cpp/inc/PhotonPeer.h"
#include "Photon/Photon-cpp/inc/PhotonListener.h"
#pragma warning (default: 4263)
#pragma warning (default: 4264)
#if _EG_WINDOWS_PLATFORM
#include "HideWindowsPlatformTypes.h"
#endif
#include "DALGameInstance.generated.h"

/**
 * 
 */
UCLASS()
class DALGAME_API UDALGameInstance : public UGameInstance
{
    GENERATED_UCLASS_BODY()

public:
    //UDALGameInstance(const class FObjectInitializer& ObjectInitializer);
    ExitGames::Photon::PhotonPeer* peer;
    ExitGames::Photon::PhotonListener* listener;
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = DALGameInstancePhoton)
    FString ServerAddress = "127.0.0.1:5055";
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = DALGameInstancePhoton)
    FString ApplicationName = "MasterServer";
};

DALGameInstance.cpp

// Fill out your copyright notice in the Description page of Project Settings.

#include "DALGame.h"
#include "DALGameInstance.h"

UDALGameInstance::UDALGameInstance(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
    peer = new ExitGames::Photon::PhotonPeer(*listener, ExitGames::Photon::ConnectionProtocol::UDP);
    UE_LOG(LogTemp, Warning, TEXT("Connecting to server"));
    if(!peer->connect(*ServerAddress, **ApplicationName**))
    {
        UE_LOG(LogTemp, Warning, TEXT("Connection failed"));
    }
    else
    {
        UE_LOG(LogTemp, Warning, TEXT("Connection established"));
    }
}

The part with ApplicationName is the problem. BuildTool complains No suitable conversion from FString to const nByte. I have tried everything to get this up and running but with no luck at all.

Does someone have the same issue or a hint at what I missed?

\$\endgroup\$
1
\$\begingroup\$

Found a solution with help from Exitgames.

Hi again,

thanks for the answer over at exitgames. Found a solution so far with this:

DALGameInstance.h

/* ToDo: Find a way to get nByte as UPROPERTY! */
//UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = DALGameInstancePhoton)
nByte* ApplicationName = reinterpret_cast<nByte*>("MMOServer");

DALGameInstance.cpp

if(!peer->connect(*ServerAddress, ApplicationName))

Try to implement listener now and view. Thanks for your help.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.