Author Topic: adventures in upgrading from Tnet2 to Tnet3  (Read 1748 times)

phoenix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 49
    • View Profile
adventures in upgrading from Tnet2 to Tnet3
« on: October 19, 2016, 09:34:50 PM »
Hi Aren,
I just wanted to document my adventures upgrading from Tnet2 to Tnet 3

The first issue I came across and resolved was the create methods
Tnet2
TNManager.Create(PrefabGameObject,false);
Tnet3
TNManager.Instantiate("OnCreate1",PrefabGameObject.name,false);

Now I need to put the PrefabGameObject in the resources folder whereas before I had an array of GameObjects on TNManager. I gather from the examples that this is the preferred/best way to instantiate in Tnet3?

The next Issue I had was getting the local IP, on my Mac my network interface status comes up as unknown for some reason so I had to change the code
for TNTools static public List<NetworkInterface> networkInterfaces and add

(ni.OperationalStatus == OperationalStatus.Up ||
ni.OperationalStatus == OperationalStatus.Unknown))

Not sure why this was changed from Tnet2 to Tnet3 but I personally need to include  OperationalStatus.Unknown
                  

TNServerInstance is a  MonoBehaviour
which I had to comment out  TNServerInstance {// : MonoBehaviour
This is the same in Tnet2 and Tnet3, is there any particular reason why TNServerInstance is a monobehavior?


And then replaced all the broadcast function handlers to handle the events directly (easy)

Now as per our discussion in this http://www.tasharen.com/forum/index.php?topic=14881.0 I have realized that the new Channels functionality solves the need for the rest of my Tnet 2 customization's and the next step will be to get back to the main Tnet3 code base with only the minor modifications noted above.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: adventures in upgrading from Tnet2 to Tnet3
« Reply #1 on: October 21, 2016, 08:52:30 PM »
The Operation.Unknown is already like that in TNet 3. What version are you using?
  1.                                 foreach (NetworkInterface ni in list)
  2.                                 {
  3.                                         if (ni.Supports(NetworkInterfaceComponent.IPv4) &&
  4.                                                 (ni.OperationalStatus == OperationalStatus.Up ||
  5.                                                 ni.OperationalStatus == OperationalStatus.Unknown))
  6.                                                 mInterfaces.Add(ni);
  7.                                 }
The TNServerInstance is a MonoBehaviour because it needs the OnDestroy notification. If you choose to make it single threaded (#define SINGLE_THREADED) it also uses the Update function. I'm not sure why you were trying to change it.

phoenix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 49
    • View Profile
Re: adventures in upgrading from Tnet2 to Tnet3
« Reply #2 on: October 23, 2016, 03:22:17 PM »
I had to change the function

static public List<IPAddress> localAddresses
the line of code
if (ni == null || ni.OperationalStatus != OperationalStatus.Up) continue;

changed to
                     if (ni == null || ni.OperationalStatus != OperationalStatus.Up){
                        if(ni==null){
                           continue;
                        }
                        else{
                        }
                     }
This is not good code but shows where the problem is

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: adventures in upgrading from Tnet2 to Tnet3
« Reply #3 on: October 24, 2016, 07:04:47 AM »
Ah, I see. I'll make proper changes, thanks.