2 Photon Cloud questions

Hi, apologies in advance as i am a noob at networking.
i am trying to make my game say check your internet when it fails to connect. I am testing this by disconnecting from the net when i login. I want it to execute the OnFailedToConnect() method. however what i get is

Connect() failed: System.ArgumentNullException: Argument cannot be null.

here is my code:

[code2=csharp]void OnFailedToConnectToPhoton(){
//Debug.Log(cause);
GameObject.FindGameObjectWithTag("Connecting").GetComponent<UILabel>().text = "Could Not Connect, Check to see if you have internet.";
}[/code2]

so yea, i dont understand why this code doesnt get executed.

my other problem, is i am trying to set up a lobby to view created games.

i have a button to create a game and all it does is this:

[code2=csharp]PhotonNetwork.CreateRoom(PhotonNetwork.playerName + "'s Room", true, true, 6);[/code2]

and i know it gets into the room, because i have a guiLabel setup in my start script just like in the marco polo tutorial.

[code2=csharp]GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());[/code2]

the problem is when i try to view rooms in the master server (on a second client), it comes up with 0 rooms.
the code i have as i login is (sorry for my NGUI code):
[code2=csharp]IEnumerator OnClick(){

if (enabled){

yield return new WaitForSeconds(0.1f);

if(!PhotonNetwork.connected){
UILabel uILabel = GameObject.FindGameObjectWithTag("PlayerName").GetComponent<UILabel>();

derp = uILabel.text;
PhotonNetwork.ConnectUsingSettings("0.1");
PhotonNetwork.playerName = uILabel.text;

GameObject.FindGameObjectWithTag("Connecting").GetComponent<UILabel>().enabled = true;
GameObject.FindGameObjectWithTag("Connecting").GetComponent<UILabel>().text = "Connecting!";

}

}

}


void OnJoinedLobby(){

Instantiate(master);

GameObject masterServerMenu = GameObject.FindGameObjectWithTag("MasterServer");
UILabel welcomeLabel = GameObject.FindGameObjectWithTag("WelcomeLabel").GetComponent<UILabel>();
masterServerMenu.transform.parent = GameObject.FindGameObjectWithTag("Panel").transform;
masterServerMenu.transform.localPosition = Vector3.zero;
masterServerMenu.transform.localScale = Vector3.one;

welcomeLabel.text = "Welcome " + PhotonNetwork.playerName;
Debug.Log(PhotonNetwork.connectionState);


Destroy(GameObject.FindGameObjectWithTag("Login"));

Debug.Log(PhotonNetwork.GetRoomList().Length);
}[/code2]

so inside my OnJoinedLobby method, i have a debug that shows the connection state and a debug that shows the room list length.
when i create a room in one client it says that client has created and joined the room, yet when i login to the lobby on a 2nd client, it shows the connection state as connected and the GetRoomList().Length as 0.

any help is appreciated, also if there is any photon cloud tutorials on setting up lobbies for a chat program or something, i would love to see them.

Comments

  • Connect callback:
    This is only called when there was a network issue of some sort. In your case, a Exception happened in Connect and that's something you want to fix first.
    What does your connect calling code look like? Any idea what is causing the ArgumentNullException?
    Testing with 127.0.0.1 while not running the server or some non-existing local-network IP, the errors are fetched and turned into calls to OnFailedToConnectToPhoton.

    Room list length:
    Nice find. In OnJoinedLobby you don't have the list of rooms yet, so this is 0. Getting the response to "Join Lobby" and getting the room list are actually 2 different things.
    Usually, OnJoinedLobby just sets a state to display the list, which is coming next.
    If you wanted to, you could implement OnReceivedRoomList and OnReceivedRoomListUpdate.
    Maybe we can call OnJoinedLobby later, when the list is actually available. Maybe that's less confusing.
  • Thanks heaps Tobias. i now have a sweet running lobby. as for the first problem, i dont know what is causing the nullexception. i will ask again later down the track, with more details if i still haven't figured it out.
Sign In or Register to comment.