LiteLobby Thread Failure in Unity3d

ktweedy1
ktweedy1 ✭✭
edited August 2010 in Photon Server
When I start Unity, before I create an instance of the Game class i see the following errors int the Unity console. I put a comment down in the log where I do create the Game instance and call connect. Some how its calling the LobbyHandler DebugReturn function before I ever create the LobbyHandler instance.


Lobby: Error trying to receive. Exception: System.Threading.ThreadAbortException: Thread was being aborted

at <0x00000> <unknown method>

at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_thread_interruption_checkpoint ()

at (wrapper managed-to-native) System.Threading.Thread:Sleep_internal (int)

at System.Threading.Thread.Sleep (Int32 millisecondsTimeout) [0x00000]

at ExitGames.Client.Photon.NConnect.Run () [0x00000]

(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)

Lobby: nPeerReturn():Exception

(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)

Lobby: Exception(ed) peer.state: 3

(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)

InvokeUpdateGameList: 0 Exception while running.

(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)

Mono: successfully reloaded assembly
Reload assembly time: 0.314294
DNVLGameController:Awake()
UnityEngine.Debug:Log(Object)
DNVLGameController:Awake() (at Assets\DNVL\DNVLGameController.cs:33)

(Filename: Assets/DNVL/DNVLGameController.cs Line: 33)

DNVLGUISceneStart:Start()
UnityEngine.Debug:Log(Object)
DNVLGameController:Start() (at Assets\DNVL\DNVLGameController.cs:56)

(Filename: Assets/DNVL/DNVLGameController.cs Line: 56)



********************************************************
I don't create a Game instance till here.
********************************************************

Lobby: nPeerReturn():Connect

(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)

Lobby: Connect(ed)

(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)

InvokeUpdateGameList: 0 Joining lobby.

(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)

Lobby: Ev: 1 Data: {}

(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 1783)

Comments

  • did you correctly port the code for unity

    you can't drop over the .net code into unity and have it work because you need to code it a bit differently or it will crash as you try to call from anything but the main thread into unity which will not work as unity is not threadsafe and does not support that.

    you can look at the normal lobby for an example of how to do it, but generally you do it by processing the incomming messages in Update and then handle the messages you find and call the corresponding things right there. That way its all in the main thread and "fine"
  • Thats fine all of the errors are happening before I even create a Game class in Unity.

    What I did find is if I close Unity and start it again. The first time I run the program I do not get these errors. I then restart my scene and I will get these errors. Also after starting the scene, once I leave Unity, I get Unity crashes.

    I am basically doing the same as the MMO demo. I pass a IGameListener to the LobbyHandler that lets the LobbyHandler call into functions in my Unity3D NetworkController script. As far as I can tell I am doing the same as MmoDemo.

    The other thing to note is it works, I am able to connect and get new Room events and everything. The only problem is this thread error I get when I start the application. Seems the thread is still running from the previous play. I am calling disconnect in the OnApplicationQuit and get back disconnect events.

    So it is working, just lke to clean up these exceptions I am seeing.
  • The LobbyHandler has its own timer internally. You would have to call LobbyHandler.Stop() and only if its peer calls PeerStatusCallback(StatusCode.Disconnect), the timer is reset to null.
    The only other thread that's used is internal in the Photon library to receive incoming data. It stops after a disconnect but could be stopped manually by Peer.StopThread().
  • Hi, yes, i hadn't got back to let you know. I found that the timer stop wasn't getting called. So now I call LobbyHandler.Stop on my application quit and it seems to have fixed this problem.

    Thanks.