Author Topic: RFC function not recieving message  (Read 2274 times)

Dustin_00

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 7
    • View Profile
RFC function not recieving message
« 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: RFC function not recieving message
« Reply #1 on: February 01, 2014, 07:03:33 PM »
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.

Dustin_00

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: RFC function not recieving message
« Reply #2 on: February 01, 2014, 09:23:04 PM »
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.  ;)

Dustin_00

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: RFC function not recieving message
« Reply #3 on: February 01, 2014, 10:23:25 PM »
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...

Dustin_00

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: RFC function not recieving message
« Reply #4 on: February 01, 2014, 10:29:25 PM »
Yep, this fixes it:

  //GameObject container = new GameObject();
  GameObject container = GameObject.Find("Globals");

Wow... so simple... so deadly.