Author Topic: Making TNManager more customizable  (Read 1075 times)

Bradamante3D

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 79
    • View Profile
Making TNManager more customizable
« on: April 30, 2016, 05:14:05 AM »
Hi,

using TNet 3 I've now run into a bit of a problem. I will propbably start using other assets at one point, stuff like uFrame or the Entitas framework. The problem is that some methods in TNManager, especially JoinChannel are not really compatible with them. Methods like JoinChannel provide a lot of functionality, in this case loading a level. Other methods create a prefab. uFrame or Entities however handle these tasks differently. Sure I could just edit the TNManager class, but that would be a problem with future updates.

So, could you in future updates make TNManager more customizable? For example, by marking methods like JoinChannel as an override? Or make TNManager a partial class?
#301224014, #301432336, #302399130

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Making TNManager more customizable
« Reply #1 on: April 30, 2016, 08:00:15 AM »
But... you already can customize it. Did you see that it inherits TNEvents class and all the delegate functions within, including onLoadLevel that defines what happens when a load level packet comes in? Just look what happens in TNManager.SetDefaultCallbacks.

Bradamante3D

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 79
    • View Profile
Re: Making TNManager more customizable
« Reply #2 on: May 01, 2016, 01:59:03 PM »
Hm, I'm lost. For one, there is no TNManger.onCreateChannel. Shouldn't there be one?

For two, when I do:

  1. class MyManager () {
  2.  
  3. void Start () {
  4.  
  5.                         TNManager.onJoinChannel = HandlerJoinChannel;
  6.                         TNManager.onLoadLevel = HandlerLoadLevel;
  7.                 }
  8.  
  9.                 void OnDisable () {
  10.  
  11.                         TNManager.onJoinChannel = null;
  12.                         TNManager.onLoadLevel = null;
  13.                 }
  14.  
  15. static public void HandlerJoinChannel ( int channelId, bool success, string msg ) {
  16.  
  17.                         Debug.Log ( "HandlerJoinChannel" );
  18.                 }
  19.  
  20.                 static public void HandlerLoadLevel ( int channelId, string eventName ) {
  21.  
  22.                         Debug.Log ( "HandlerLoadLevel" );
  23. }
  24. }

nothing gets printed. But Debug.Log messages added to the TNManager.JoinChannel and TNGameClient.JoinChannel functions are being logged. But I want to circumvent those to have my own scene loading.
#301224014, #301432336, #302399130

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Making TNManager more customizable
« Reply #3 on: May 03, 2016, 01:11:53 PM »
You need to use += not =. You're overwriting TNet's functionality, when you should be adding to it instead.

To have your own level loading just set TNManager.onLoadLevel. The defaults are all set in TNManager.SetDefaultCallbacks.