Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by goutham12 · Jun 14, 2017 at 02:12 AM · photon

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ChristianSimon · Jun 15, 2017 at 08:33 AM

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);

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image goutham12 · Jun 15, 2017 at 09:35 AM 0
Share

Thanks for your replay. i tried but i faced an error while rejoin

like..

  • error

Operation failed: OperationResponse 226: ReturnCode: 32748 (Actor with number 0 not found.). Parameters: {} Server: GameServer $$anonymous$$y flow is like.

in my scenario first player connects to the lobby. So i kept room options in The method Public static bool JoinOrCreateRoom().(which in photonnetwork class)

after the player disconnected from internet is anything i have to do?

avatar image ChristianSimon goutham12 · Jun 15, 2017 at 09:46 AM 1
Share

If the client completely disconnects from the internet you have to reconnect to Photon first. Using PhotonNetwork.ReconnectAndRejoin(); is the easy way in this case. $$anonymous$$ake sure to set PlayerTtl and EmptyRoomTtl to values which you don't exceed before you start the rejoin process.

If you still have problems please provide some code snippets. This makes solving the problem easier in my opinion.

avatar image unity_gRMpvwqEmWscxw · Jul 31, 2019 at 07:55 AM 0
Share

How do I know that the player who reconnects belongs to this room though?

Say, if a player with photonid 2 disconnects, and reconnects with photonid 4 because other players connected before he could reconnect, how do I know this player belongs to this room?

OR, does photon network maintain the player's ID for the amount of time specified by options.PlayerTtl ?

avatar image
0

Answer by goutham12 · Jun 15, 2017 at 10:04 AM

// 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[i]);
         PlayerOL[i] = new PlayersOnline(PlayersInfoLst[i].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();

 }

}

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ChristianSimon · Jun 15, 2017 at 12:06 PM 2
Share

When you call PhotonNetwork.LeaveRoom(); the client will be removed from the room as well as from the server's memory. Rejoining after calling LeaveRoom() is not possible. You can only reconnect and rejoin after you have lost and restored internet connection.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

112 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

NullReferenceException 0 Answers

A MindBreaking MonoBehaviour Issue!. (Unity3D v5.1.0f Pro: unityserializer-ng VS Photon Unity Networking) 0 Answers

Unity Audio Networking Stops Playing after 10s 0 Answers

Both players reach same time how to get result draw in photon unity 1 Answer

Photon Player And Weapon View Error 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges