using Photon.Realtime;
using System.Collections.Generic;
using Hashtable = ExitGames.Client.Photon.Hashtable;
public class CreateRoomWithLobbyPropertiesExample : IMatchmakingCallbacks
{
public const string MAP_PROP_KEY = "map";
public const string GAME_MODE_PROP_KEY = "gm";
public const string AI_PROP_KEY = "ai";
private LoadBalancingClient loadBalancingClient;
private void CreateRoom()
{
RoomOptions roomOptions = new RoomOptions();
roomOptions.CustomRoomPropertiesForLobby = { MAP_PROP_KEY, GAME_MODE_PROP_KEY, AI_PROP_KEY };
roomOptions.CustomRoomProperties = new Hashtable { { MAP_PROP_KEY, 1 }, { GAME_MODE_PROP_KEY, 0 } };
EnterRoomParams enterRoomParams = new EnterRoomParams();
enterRoomParams.RoomOptions = roomOptions;
loadBalancingClient.OpCreateRoom(enterRoomParams);
}
// do not forget to register callbacks via loadBalancingClient.AddCallbackTarget
// also deregister via loadBalancingClient.RemoveCallbackTarget
#region IMatchmakingCallbacks
void IMatchmakingCallbacks.OnCreateRoomFailed(short returnCode, string message)
{
// log error message and code
}
void IMatchmakingCallbacks.OnCreatedRoom()
{
}
void IMatchmakingCallbacks.OnJoinedRoom()
{
// joined a room successfully, OpCreateRoom leads here on success
}
// [..] Other callbacks implementations are stripped out for brevity, they are empty in this case as not used.
#endif
}