Tasharen Entertainment Forum
Support => TNet 3 Support => Topic started by: Dustin_00 on February 01, 2014, 04:01:33 PM
-
Been stuck here for a while. I can see all my comments as I step through getting into a group chat.
Initialize, Find Server, enter the server's Lobby, join channel, then:
tno.Send("OnChat", Target.All, TNManager.playerID, message);
But the
[RFC] void OnChat
never gets called.
Any suggestions on how to identify where my disconnect is?
-
Most common cause -- you didn't give a proper TNObject ID.
Zero ID means it will only work if you instantiate it dynamically.
If it's a static object (present in the scene on load) you must give it a unique TNObject ID.
Nested TNObjects always use their rootmost object's ID.
-
Thank you for responding!
Some more details:
I have an empty root object called Globals. It has the TNManager, TNObject (Id = unique number, I've tried several now), and my custom script with the OnChat function.
I set a break point on the tno.Send() command and did "Step Into" and stepped all through the code... AND THAT WORKED!
So then I run without the break point... doesn't work.
Now I'm remembering why I dislike networking code. ;)
-
Ah! I think I see what I've done.
The actual Chat functions are in a singleton that the Global.HostScript is calling.
When the Singleton is created...
GameObject container = new GameObject();
container.name = "Chat";
_Instance = (Chat)container.AddComponent(typeof(Chat));
So I am creating it dynamically at run time. Sounds like if I attach it to the HostScript's GameObject, I might be back on track...
-
Yep, this fixes it:
//GameObject container = new GameObject();
GameObject container = GameObject.Find("Globals");
Wow... so simple... so deadly.