Author Topic: TNet 3 - Suggestion or Explanation  (Read 2086 times)

xandeck

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 3
  • Posts: 54
    • View Profile
TNet 3 - Suggestion or Explanation
« on: May 18, 2016, 09:30:55 AM »
Hello Aren,

From time to time I have some problems in my code (which is really normal for programmers).
But using TNet, strangely, the Unity debug returns me errors as it were in your TNet (but it is not).
In example: I have an array like

  1. int[] myArray = new int[3];
  2.  

If I send a tno.Send to someone that still has not this array initiated, instead of Unity showing a problem in my code, it shows as TNet error, like the one below:

  1. [TNet] Failed to call TNO #16777190 function _SoldierPlayerController._NetReceive_ConfigCharacter
  2.  

But it is actually not a problem related to TNet itself. It was something that I forgot to initiate in one of my arrays (a line that came right next to receive the RFC command, in same function).
Is there any way that we can improve this or anything I can do on my side?
Thank you

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: TNet 3 - Suggestion or Explanation
« Reply #1 on: May 21, 2016, 04:10:51 PM »
TNet wraps execution of RFCs in a try-catch block. You can see this (in TNet2 at least, probably the same in TNet3) in TNUnityTools.cs @ ExecuteAll(...) function.

When an exception occurs, it's caught by that block and printed out accordingly. This is why it'll always show as a "TNet error", even though TNet is just reporting the error. TNet does report the actual exception, along with the stack trace, you just have to scroll down a bit.

If you'd like to change this behaviour just modify the PrintException(...) function in TNUnityTools.cs, or remove the try-catch block in ExecuteAll(...) if you'd like to handle exceptions yourself (not recommended).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNet 3 - Suggestion or Explanation
« Reply #2 on: May 21, 2016, 10:19:50 PM »
What cmifwdll said. :)

The only correction is that in TNet 3, execution happens in the TNObject.Execute function, line 472. The methods are all cached for best performance.