Author Topic: New TNET Project  (Read 4349 times)

yo_milo

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 2
  • Posts: 36
    • View Profile
New TNET Project
« on: August 17, 2015, 04:24:22 PM »
My last TNet project was a huge success. (Thank you Aren...)

However; it was a WLAN game, so, I did not have to worry about servers at all.

But now, I want to try doing something to be played online. I see a lot that you mention Amazon EC2 server as a hosting solution. I would like to know, what should I look for in a server in order to have a game using TNET working on it. The load should not be too much, yet; it should be stable.

I am asking this, because we might get a Server to host our own leaderboards (We are not using neither Play Services, or Game Center) using PHP, and we would like to kill two birds with one stone. Is there anything specific I should look for in order to run TNET on the server?

Or, am I getting all tangled up?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: New TNET Project
« Reply #1 on: August 18, 2015, 05:47:53 PM »
There is really not much to it. I recommend Windows servers as TNet's usage of IO Completion ports works on Windows, resulting in faster performance there. Amazon EC2 is mentioned because you can have a micro instance free for an entire year -- good enough to host a lobby server on. For Windward I grabbed a medium size Amazon instance instead, although it hasn't been needed since the first few weeks of launch. First week of Windward I was actually hosting a server with over 300 concurrent players on it right from Visual Studio debugger in on my computer in my home with a 20 Mbit upstream connection. TNet was using about ~3% CPU on average with that many players there.

For Starlink I handled leaderboards by having a pair of PHP scripts here on tasharen.com that get called when the player saves their profile and when they want to retrieve the leaderboard list. It's a good solution as it allows the information to also be accessible from within your browser without having to launch the game.

acronyte

  • Newbie
  • *
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 46
    • View Profile
Communicating to TNet through browser / php?
« Reply #2 on: July 26, 2017, 10:35:38 AM »
This is quite interesting, it opens doors for communicating to tnet through a browser/ php....

Lets say I have a datanode with
data1 = "1"
data2 = "2"

How do I get the values "1" and "2" from Tnet to show as a simple text in my browser through php?

Im guessing this is how players can check the leader boards without having to log in / load the actual game (they just check the data in thier browser?)

For Starlink I handled leaderboards by having a pair of PHP scripts here on tasharen.com that get called when the player saves their profile and when they want to retrieve the leaderboard list. It's a good solution as it allows the information to also be accessible from within your browser without having to launch the game.

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: New TNET Project
« Reply #3 on: July 26, 2017, 10:21:08 PM »
Interacting with web services is something you'd have to add in yourself. TNet's only web stuff right now just displays the name of the server and names of each connected player.

You can use WebClient for what you want, though, and I'm pretty sure this is probably what ArenMook used in his described setup.

https://msdn.microsoft.com/en-us/library/system.net.webclient(v=vs.110).aspx it supports both GET and POST.

Getting data from TNet to the webserver to then display to the webclient requires pushing this data to the webserver (like POSTing to a secret PHP script that only the gameserver uses) as it changes on the gameserver. You'd have to modify the gameserver quite a bit for what you want, I think. It might be easier to expand TNet's webserver functionality and forgo php scripts altogether, but that gets dangerously close to reinventing the wheel.

Oh, on second thought, if you want to trust your clients, you could just have them get the data from TNet (GetChannelData, GetServerData, etc) and POST it to the webserver themselves. This eliminates the need to modify any of TNet's code. This would just take place in your game code.

acronyte

  • Newbie
  • *
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 46
    • View Profile
Re: New TNET Project
« Reply #4 on: July 31, 2017, 09:32:44 AM »
Makes sense.....Thank you. Ill give it a try and see....

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: New TNET Project
« Reply #5 on: August 03, 2017, 04:29:26 AM »
I was actually using Unity's HTTP request iirc. The game's client is what was communicating with the web server, not TNet.