Author Topic: Having trouble getting my head around Tnet  (Read 5007 times)

matt1

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 28
    • View Profile
Having trouble getting my head around Tnet
« on: July 30, 2013, 11:37:53 AM »
Hi there,

I am having trouble understanding Tnet, mainly getting my head around how it works.

So I have the server, and a client, and somebody can be a host? but I want to leave that part out, as I want to host everything.

Now, after following the tutorial, I see most stuff is sent from the client to the server, and relayed to others. How secure is this? Wouldn't people be able to capture the packets from the client and send them to the server, or even edit data before that?

Also i'm a little confused on how the server works, would I be able to set a string on the master server for example a build number, and if the client's build number didn't match, then don't let them connect?

Also, are there any other tutorials other than the ones on your youtube?

Thanks in advance!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Having trouble getting my head around Tnet
« Reply #1 on: July 30, 2013, 04:29:29 PM »
TNet uses TCP as primary means of communication, so unless your game connects to a hacked PC that then forwards the connection, nothing will happen to your packets. That said, sure -- a determined person could get "in-between" and sniff the packets for the data and what have you. So if you need to transfer something really secure, encrypt it or shuffle it first. It's up to you to do that. In 99.9% of the games this is not required.

With TNet you can have a master server (lobby server) where actual game servers register. Think of it as a server list in World of Warcraft -- you go through authentication and get a server list, and then you can connect to the actual server of your choice. When ready, the user chooses the server and connects to it, and when connected they can check what channels are present, join a channel, see who else is in the channel, etc. A "host" is just another player who's chosen to be the "leader". There is always only one host per channel. You will generally use the "host" if you want the AI logic to run only on one PC, and have that PC send the result to everyone else. The host will be running the AI logic.

If you want, you can also modify the server itself to have the AI logic there, but it's generally far easier to keep it on the clients.

TNet takes care of the build versioning and not letting connect on a mismatch. Just increment the TNet.Player.version number.

matt1

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 28
    • View Profile
Re: Having trouble getting my head around Tnet
« Reply #2 on: July 31, 2013, 08:15:38 AM »
Okay, that makes it a little easier to understand.


However I am still at loss with the build version, the reason I asked, was not to verify a build, but to be able to just check with something on the master before connecting.

if I wanted to have this string, just for learning purposes, how would I do it? Would I edit the server source? And have it there, or would one of the clients I scripted hold it?

thanks again

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Having trouble getting my head around Tnet
« Reply #3 on: July 31, 2013, 12:29:24 PM »
On a per-server basis? Easiest thing to do is just to include it in the server name. For example of having "My Server" call it "My Server|123". When you get the server list from the lobby, just parse it using string.Split on the "|" character and int.TryParse the 2nd value.