Does Native Library Support Master Client and Host Migration?

Options
Hi Photon Team,

I read https://doc.photonengine.com/en-us/realtime/current/reference/hostmigration .

I have 2 player in game A and B.

When MasterClient A lost connection the room been closed.

B is not became MasterClient.

1. Do I need some setting in code?
2. What is the equal function "PhotonNetwork.SetMasterClient()" in c++ libray?

Thanks for your help!

Comments

  • Owen
    Options
    Hi Photon Team,

    Sorry! My bad!

    This is because , when Player A lost connect , I will call disconnect in Player B.

    sorry!

    Photon Master Client and Host Migration works perfectly!

  • juaxix
    juaxix ✭✭
    edited January 2021
    Options
    The C++ API changed right?
    SetMasterClient is still there:
    https://doc.photonengine.com/en-us/realtime/current/gameplay/hostmigration but I don't see a clear way to call it or implement a method in a custom LoadBalancingClient (nor MutableRoom) to access this info without changing LoadBalancing, how can I do that?
    I guess ,that to overload a custom type making a fake string that holds a nByte to change the room property with something like this is really crazy innit?.

    
    //----
    static TSharedPtr<nByte> tempData = MakeShared<nByte>(ExitGames::LoadBalancing::Internal::Properties::Room::MASTER_CLIENT_ID);
    			const FNByteFakeString fakeNByteString(tempData.Get());
    			ExitGames::Common::Hashtable hash;
    			hash.put(fakeNByteString, static_cast<int>(PlayerNumber));
    			//auto merged = ExitGames::LoadBalancing::Internal::Utils::stripKeysWithNullValues(hash);
    			return Room.addCustomProperties(hash);
    //---
    
    //having
    class FNByteFakeString : public ExitGames::Common::Object
    	{
    	public:
    		nByte Data;
    		FNByteFakeString(nByte* InData)
    			: Object(InData, ExitGames::Common::TypeCode::STRING, ExitGames::Common::TypeCode::STRING, true)
    			, Data(*InData)
    		{
    		}
    		nByte& operator=(nByte aNum)
    		{
    			Data = aNum;
    			return Data;
    		}
    		bool operator==(const nByte& Rhs) const
    		{
    		  return Data == Rhs;
    		}
    
    		virtual ExitGames::Common::JString typeToString() const override
    		{
    			return "STRING";
    		}
    
    		virtual ExitGames::Common::JString& toString(ExitGames::Common::JString& retStr, bool withTypes) const override
    		{
    			return retStr;
    		}
    	};
    
    namespace ExitGames
    {
    	namespace Common
    	{
    		namespace Helpers
    		{
    			template<> struct ConfirmAllowedKey<FNByteFakeString>
    			{
    				typedef nByte type;
    				static const nByte typeName = TypeCode::STRING;
    			};
    		}
    	}
    }
    
    
  • Kaiserludi
    Options
    Hi @juaxix.
    I guess ,that to overload a custom type making a fake string that holds a nByte to change the room property with something like this is really crazy innit?.
    Doing so won't work, as you would then send that value with a string key, but the server treats properties with string keys as custom properties and properties with bytes keys as built-in properties.
    So you can't fake a built-in property this way.

    Setting the master client from the client side is not currently supported by the C++ client.