Rejoin in photon network?

Hi all,
Am doing a multiplayer game. If one player is disconnected other can continue like clashroyale.
If the disconnected person came with in the session I have to make him rejoin into that room .

I don’t know how to do rejoin.
Can anyone help me with explain it. Just idea is enough.

Thank you

Hi,

when the client is completely disconnected from Photon you can use PhotonNetwork.ReconnectAndRejoin(); to firstly reconnect to Photon and to rejoin the room afterwards. PhotonNetwork.ReJoinRoom("RoomName"); does the same but you have to reconnect to Photon before manually.

Both options requires you to set up the room correctly by using the RoomOptions. Using this options you can set PlayerTtl and EmptyRoomTtl to something else than 0. PlayerTtl describes how long the client’s data will remain in the server’s memory. EmptyRoomTtl does the same for the (empty) room itself.

RoomOptions options = new RoomOptions();
options.PlayerTtl = 60000; // 60 sec
options.EmptyRoomTtl = 60000; // 60 sec
PhotonNetwork.JoinOrCreateRoom("RoomName", options, null);

// find match

OnBattle()
{

TypedLobby  loby = new TypedLobby();
loby.Name = LobbyName;
PhotonNetwork.JoinLobby(loby );	

}

the above method automatically call joinorcreateroom(). in the method joinorcreate()(which is in photon networkclass)
i kept room options what you gave.

// here is the code.

public static bool JoinOrCreateRoom(string roomName, RoomOptions roomOptions, TypedLobby typedLobby, string expectedUsers)
{

	roomOptions = new RoomOptions();
	roomOptions.PlayerTtl = 60000; // 60 sec
	roomOptions.EmptyRoomTtl = 60000; // 60 sec

    if (offlineMode)
    {

//when player connectd

public void OnPhotonPlayerConnected(PhotonPlayer player)
{
InitAndAddOwnPlayer();
}

// in this method am getting the error
public void InitAndAddOwnPlayer()
{
PlayerOL = new PlayersOnline[PhotonNetwork.room.maxPlayers];

	PhotonPlayer[]  PlayersInfoLst = PhotonNetwork.playerList;

	print("PlayerInfoList.."+PhotonNetwork.playerList);
	for(int i=0;i<PlayersInfoLst.Length;i++)
	{
		print("PlayerInfo______"+PlayersInfoLst*);*

PlayerOL = new PlayersOnline(PlayersInfoLst*.name,“0”,“0”);*
* }*
* CloseRoomBasedOnPlayers();*
}
after that am making room.visible = false; and am starting the game for both players.
now if one was disconnected am doing…
if (LevelManager.THIS.isInternetAvailable == false && onetimecall) {
* if (LevelManager.THIS.gameStatus == GameState.Playing) {*
* PhotonNetwork.LeaveRoom ();*
* PhotonNetwork.LeaveLobby ();*
* }*
}
// rejoin
now he connects again
if(LevelManager.THIS.isInternetAvailable && onetimecall) {
* if (LevelManager.THIS.gameStatus == GameState.Playing) {*
* PhotonNetwork.ReconnectAndRejoin();*
* }*
}