Search Unity

OnJoinRoom firing multiple times in SFS

Discussion in 'Multiplayer' started by matrix211v1, Sep 23, 2009.

  1. matrix211v1

    matrix211v1

    Joined:
    Jan 20, 2009
    Posts:
    193
    Ok, here is my issue. I have created each scene to be a room. When a user moves from one room to another, I call LeaveRoom then I load the new scene. Each scene has it's own "NetworkController" where I got the example from the SFSIsland Demo. There is NO DontDestroyOnLoad in any code. Each scene has it's own Prefab of the "NetworkController".

    In the Start function of the NetworkController.cs, I have this:

    Code (csharp):
    1.     void Start() {
    2.         Debug.Log("NetworkController: Start");
    3.         Application.runInBackground = true; // Let the application be running whyle the window is not active.
    4.         smartFoxClient = GetClient();
    5.         if (smartFoxClient==null) {
    6.             Application.LoadLevel("LoginScreen");
    7.             return;
    8.         }  
    9.         SubscribeEvents();
    10.         started = true;
    11.         smartFoxClient.JoinRoom(Application.loadedLevelName);
    12.         Debug.Log("NetworkController: Finish");
    13.     }
    And it works wonderful the first time I enter the room. I see all the other players, everything is fine.

    Now, I go to a new scene from within the game. As I mentioned, I call "LeaveRoom" and I load the new scene.

    This is the problem: OnJoinRoom will fire 2 times. If I go into another scene, it will fire 3 times, another scene, it will fire 4 times and so on for however many scenes I try and connect within the game.

    It's almost like there is a counter following it. I have NO CLUE where to start looking to track this down. I thought to look into the ProcessEventQueue and maybe clear it out or something when a new scene is loaded but I don't even understand it's purpose let alone how to clear it out.

    Any thoughts? I can provide the 2 scripts if anyone wants to look at them (the 2 scripts are the NetworkController and PlayerSpawnController from the SFSIslandDemo).

    Thanks in advance.