Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: richardwood on August 21, 2014, 03:42:07 AM

Title: RFC or Custom packets instead?
Post by: richardwood on August 21, 2014, 03:42:07 AM
Hey, so far I've been watching two TNet videos, I'm a beginner developer I'm a bit confused on this part. Assume I want to make a simple chat room. Should I use RFC which on every client there's a remote functions on

Or should I just ditch this RFC, and create a custom packets. Add codes on the server, tell it what to do case by case depending on what packet it's receiving.
*New Player Joins -> client send request packet to the server* =>
*server accepts the request -> server sending back list of players that is currenly in the room to that newly joined player*

*a player sending a message -> client send message packet to the server* =>
*server accepts the message packet -> server relays that message to all players in channel*

*etc*

So in short, when I should use RFC and when should i use custom packets? Thanks
Title: Re: RFC or Custom packets instead?
Post by: ArenMook on August 22, 2014, 04:44:56 AM
Stick to RFCs. It's way easier.

Also note that OnNetworkPlayerJoin, OnNetworkPlayerLeave, OnNetworkLeaveChannel, OnNetworkJoinChannel, etc are built-in notifications in TNet. You can find them in TNManager.

So from what you mentioned, all you need to implement is the message sending RFC, which is trivial.
  1. [RFC]
  2. void ChatMessage (string message)
  3. {
  4.     Debug.Log(message);
  5. }
Then to send this message, you just use:
  1. tno.Send("ChatMessage", TNet.Target.All, "Hello world!");