Tasharen Entertainment Forum
Support => TNet 3 Support => Topic started by: bac9 on June 23, 2014, 10:10:11 AM
-
Maybe I have overlooked something in the documentation, but is OnNetworkDisconnect supposed to be called in the latest version of TNet? As far as I see, only OnNetworkConnect with the false result argument is actually being called in the event of a client being disconnected from a server, and OnNetworkDisconnect remains inactive no matter the scenario. This is reproduced on AutoJoin example shipped with TNet.
I'm not having any obstacles with that, keeping both connect/disconnect related code under OnNetworkConnect is somewhat convenient even. But I'm curious whether OnNetworkDisconnect was deprecated/deactivated or whether I'm doing something wrong (like, maybe it's only supposed to work on an object with an active TNObject)?
-
1. I launched TNServer.exe and opened the AutoJoin example.
2. Hit Play, it connects and shows the cubes.
3. Stopped the server ('q', enter) -- error message gets shown about the Main Menu scene not being present, triggered as a result of OnNetworkDisconnect.
OnNetworkConnect gives you the result of your connection attempt. OnNetworkDisconnect gives you a notification telling you that you were connected, but are now disconnected.
-
OnNetworkDisconnect not being called too~
-
Aren - OnNetworkDisconnect gets called when the server is shut down, but not when the client device loses connection. This is because TNGameClient only calls onDisconnect() when it gets a Disconnect packet. Connection loss is dealt with as an Error packet, which sees that connection state is not Connected and calls onConnect(false) - I think this is a consequence of the way errors are dealt with in the TCP/UDP protocol files. You can test this easily by running the client on a mobile device and turning off the WiFi. Note that OnNetworkConnect(false) only gets called after the timeout, it doesn't seem to notice when the connection drops.
-
Yup, known and already fixed in the Pro version as of like 3-4 weeks ago. Thanks though. From 1.9.7 version notes:
1.9.7:
- NEW: TNet is now fully Unity 5-compliant.
- NEW: SendRFC sent to the player's self will now result in immediate execution (think Target.Host).
- NEW: Added better/more informative error messages when RFCs or RCCs fail.
- NEW: TNObject inspector will now show its player owner and whether the player owns this object (at run time).
- FIX: TNManager.JoinChannel will now load the level even without TNManager.
- FIX: TNObjects will now have valid IDs even without TNManager.
- FIX: Added a null check in PrintException for when working with static RCC functions.
- FIX: OnNetworkDisconnect will now be called when the connection is shut down in a non-graceful manner.
-
Excellent, thanks. Any idea when it'll be up on the asset store?
-
Friday or Saturday night.