Author Topic: Channel List callback?  (Read 2574 times)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Channel List callback?
« on: May 10, 2014, 05:56:03 PM »
Hello !

In the FAQ you already show how to retrieve a list of channels from the server in "Q: How to retrieve a list of channels from the server?".

But what if I need a callback, every time a channel is opened or closed.

Is this something you could add to TNet or should I implement my own (and how would I do that?).
Also, what I can do is send a request to have the list of channels every 5seconds. But that's kinda ugly...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Channel List callback?
« Reply #1 on: May 10, 2014, 11:36:00 PM »
That's a useful notification. But thinking about it... can't you simply have the player do a broadcast RFC to others, letting them know that you've opened a channel with all the associated info? Half the time you probably don't want other players to be able to join right away until you "unlock" the channel.

I do that myself in Starlink -- players sitting in chat get notified of new channels, and get a hyperlink they can click to instantly join the game in progress.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Channel List callback?
« Reply #2 on: May 11, 2014, 04:08:20 PM »
Hum, yes that's a good idea.
But that means if players connect after broadcasting, they will have to make the request.
Sounds good :)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Channel List callback?
« Reply #3 on: May 11, 2014, 04:23:53 PM »
Hum... I'm trying to send a broadcast from one class, and have a RFC method in another class, but that does not seem to work.

Currently, in my class GamesUI, I do:
  1. tno.BroadcastToLAN(TNManager.listeningPort, "OnGameCreated", gameData);
(by the way, do I really need to use tno just to send a broadcast? Because of that my class do not derive from Monobehavior but from TNBehavior, and I have to attach a TNObject to the GameObject in the scene).

And in a CreatedGamesUI class, I have:
  1. [RFC]
  2. void OnGameCreated(GameData gameData)
  3. {
  4.         addGame(gameData.id);
  5. }

But I have the error message:
Quote
Unable to execute function 'OnGameCreated'. Did you forget an [RFC] prefix, perhaps?
GameObject: "UI Root/Camera/Home/2-PickGame"

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Channel List callback?
« Reply #4 on: May 12, 2014, 11:49:53 AM »
Hum... it seems in fact I need a single class, that will handle all the sending broadcast and receiving via RFC.
And from this class, I would inform whatever class I want right?

Because everyone need to share the same GameObject that can send/receive RFC calls right?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Channel List callback?
« Reply #5 on: May 13, 2014, 09:22:06 AM »
Sending and receiving of the RFCs must be on the same object. You are sending it through the TNObject after all. Meaning it goes to all players, arriving on the same TNObject.