Author Topic: RFC or Custom packets instead?  (Read 1637 times)


  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 8
    • View Profile
RFC or Custom packets instead?
« 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
  • OnPlayerJoin
  • OnPlayerSendingMessage
  • OnPlayerQuitRoom
  • and so 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*


So in short, when I should use RFC and when should i use custom packets? Thanks


  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: RFC or Custom packets instead?
« Reply #1 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!");