Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: pyscho2day on July 21, 2013, 06:17:55 PM

Title: A P2P script utilizing a Master server for anyone to use
Post by: pyscho2day on July 21, 2013, 06:17:55 PM
I have been working on a script that utilizes a Master Server to find a P2P game server for a game I am working on. First I want to tell Aren Thank you for TNET. So far it has done everything I needed and the parts I wasn't able to figure out you gave enough information so that i was able to figure out what was missing.

I am attaching the script to the file and the directions are both below and in the script file.  The file is licensed under the Apache License V2.0.  You can use it for both commercial and non commercial as long as you note any change you did to it and the license information in the summary.

Directions
 
1.  Setup TNServer so that it is running as a TCP Lobby server.
2.  If you have not already imported TNET do so now.
3.  Attach script to an empty object in unity.
4.  Make a copy of the TNManager.cs script and name it PingTNManager.cs.
5.  In PingTNManager.cs change all references from TNManager to PingTNManager.
6.  Attach PingTNManager.cs and PingPingTNManager.cs to the object from step 3.
7.  Select your Object and fill in the fields for the ConnectToMasterServer script.
 
Notes:
1.  Some of the fields can be removed as they are just for use in the Unity editor for testing.
2.  I am new to C#, Unity, and TNET so there is a high chance that things can be done better.
    If you would like to leave constructive criticism or have a change that would be useful
    please leave a reply on the thread at http://www.tasharen.com/forum/index.php?topic=5089.0
Title: Re: A P2P script utilizing a Master server for anyone to use
Post by: ArenMook on July 22, 2013, 04:27:20 AM
A thread that links to itself... interesting :P

Thanks for sharing, but why do you create a copy of the TNManager? If you need certain functionality from it, it's best to use the GameClient class like TNManager does. TNManager is just a singleton wrapper around the GameClient anyway -- there for convenience.
Title: Re: A P2P script utilizing a Master server for anyone to use
Post by: pyscho2day on July 22, 2013, 10:12:52 AM
I copied the directions from the file itself that is why the link is in there as well.

As for why I just made a copy of the TNManager was for ease of use.  I am rebuilding my own version but I did not want to include a file that had any of your code or anything vary similar.  This way if they want to use the file then they have to have TNET to use it. Yes I do recommend making your own script/class using the GameClient but again it was for ease of use for others.
Title: Re: A P2P script utilizing a Master server for anyone to use
Post by: aidji on September 13, 2013, 05:48:48 AM
Hello, I Created PingTNManager.cs and replaced every  TNManager to PingTNManager

but i still have 6 error like this:


Assets/TNet/ConnectToMasterServer.cs(482,23): error CS0117: `PingTNManager' does not contain a definition for `Connect'

[edit]oh it work, i modified the wrong script
Title: Re: A P2P script utilizing a Master server for anyone to use
Post by: pyscho2day on September 13, 2013, 11:48:14 AM
Cool, if you have any ideas for revisions or what not let me know. I have a revised one but its not ready for genpop yet. Handles start and stop of the server better so that you can enable then disable and re-enable it.