Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

[Released] TNet: Tasharen Networking Framework

Discussion in 'Assets and Asset Store' started by ArenMook, Dec 24, 2012.

  1. Martin-Schultz

    Martin-Schultz

    Joined:
    Jan 10, 2006
    Posts:
    1,377
    @thr:

    As you mention OpenTNL: I used it a lot. It is a common thing in network programming to have a serial number counter for UDP updates being transmitted along. When you receive a packet with a serial smaller than the last and highest serial, then drop the packet. This is one scenario how to avoid the issue with out of order packets with UDP.

    -----

    In general my experience so far with TNet: Awesome library. Similar as NGUI started. I'm pretty sure this will grow into something big. Well done ArenMook!
     
  2. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    @ArenMook

    You said:
    This is the first time i heard that. Can you explain more please? ;)
     
  3. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I signed up for the Amazon Micro server (the one that's free), connected to it via remote desktop and put a TNet server up there. I can now make multi-player games that will automatically connect to it. As long as they are not bandwidth-intensive, I won't need to pay anything. Of course when I do need something more bandwidth-intensive, there are plenty of other hosting options as well -- all that's needed is a Virtual Server.
     
  4. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
    (bookmarked)
     
  5. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    1.1.0
    - NEW: Added AutoSync script that can automatically synchronize properties of your choice.
    - NEW: Added AutoJoin script that can quickly join a server when the scene starts.
    - NEW: Added a pair of new scenes to test the Auto scripts.
    - NEW: It's now possible to figure out which player requested an object to be created when the ResponseCreate packet arrives.
    - NEW: You can quickly check TNManager.isThisMyObject in a script's Awake function to determine if you're the one who created it.
    - NEW: You can now instantiate objects with velocity.
    - NEW: Added native support for ushort and uint data types (and their arrays).
    - FIX: Fixed a bug with sending data directly to the specified player.
    - FIX: Resolving a player address will no longer result in an exception with an invalid address.
    - FIX: Changed the order of some notifications. A new host will always be chosen before "player left" notification, for example.
     
  6. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    P.S. Those who have the Space Game Starter Kit and NGUI can now obtain a new version of SGSK that uses TNet.
     
  7. jemast

    jemast

    Joined:
    Dec 7, 2011
    Posts:
    141
    Hello,

    I'm looking into networking solutions and yours definitely seems intersting.

    I have a few quick questions about your EC2 setup as I'm only intersted into client/master-server networking and not P2P. I may be wrong but I'm guessing you're using it for Windward. If that's the case, there are two areas where you could shed some more light for me:

    - How's your bandwidth usage? While the free tier covers a relatively large usage case and bandwidth is quite cheap, networking in games can become bandwidth intensive (it all depends on the game of course). I'm not asking for a precise figure but rather your opinion as this being a viable/not-risky option (in terms of bill) for indie/small time devs.

    - How do you manage persistence? Does the standalone server provide some hooks to add custom persistence or game logic without having to plug it right in the middle of your code (not that I mind but it makes updating path steeper). Or do you simply rely on EBS?


    Thanks!
     
  8. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Nope, I am still using Unity's built-in networking for Windward as I added it many months before I finished developing TNet. That's why there are odd glitches here and there (especially on Linux).

    If you are worried about bandwidth for your game, there are better solutions than Amazon out there. I can't give you exact specifics, as it really depends on the kind of a game you're making and how often / how much data you're sending.

    Persistence is managed by making RFC calls and specifying a "saved" type target -- Target.AllSaved, for example. The server stores this call, just like any other saved call, in the order that it was received. This will also be the order in which these calls get sent to newly connected players. Repeatedly calling the same function on the same game object will overwrite the saved "slot" each time, saving only the latest. Due to this, it's best to send packets like "here's a new list of XYZ" instead of "add XYZ to the list".
     
  9. jemast

    jemast

    Joined:
    Dec 7, 2011
    Posts:
    141
    Thanks for the quick answer.

    I'm not really worried about bandwidth usage at the moment as this is for a turn-based game so usage will be really low. Though I'm also looking into making a durable and unified solution that I could use for other games not so friendly on bandwidth usage, as well as adding other services linked to the game server (push notifications, leaderboards, you name it...). I'm not only considering Amazon but their reliability (admittedly they had a few outages but I'm not worried too much about those), flexibility and complete offering is a great starting point for a server back-end (if you omit the "guess how much we will bill you" part).

    About persistence, I was more asking about how do you persist server data to durable storage (out of memory): is this on file storage? I'd be interested in including some basic game logic monitoring on the server so that it can retain game data for some time (where all the players left the room and join back on a per-player basis at a later time) as well as push some data and stats to a database.
     
  10. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Everything that was in memory gets saved to a file. No databases are needed for something like this, as saving only happens when you request it (usually just before you shut down the server). While the server is running, persistence is achieved by keeping everything in memory.
     
  11. jemast

    jemast

    Joined:
    Dec 7, 2011
    Posts:
    141
    Makes sense.

    Thanks for your time. I still need to sort out how I'll deal with networking and online services but your solution sure looks appealing as I don't want to do it all myself when there are other people out there providing better solutions than I could come up with for just a few dollars.
     
  12. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Looks really good! Will buy it next month!
     
  13. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    Quick question:

    How hard would it be to add the "anti hack" features to Tnet that uLink has? By this I mean: player client sends rfc to server client(headless client that runs the AI for instance) saying "hey I moved through this wall". The server client tries to move the player's GameObject through the wall and cannot. My understanding is that the next step in this process would be for the server client to report back to the cheating client and say "no, go to *here* instead" and broadcast the correct position to all other clients. The pseudo code sounds simple enough in my head but wondering if this is a large or small task to accomplish with Tnet.
     
    Last edited: Jan 17, 2013
  14. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    TNet's server code doesn't run game logic unless you modify it to have it. The default server that comes with TNet is basically an echo server. One of the connected clients in the channel is designated to be the "host" (authoritative player), so it's up to you to add logic that will verify the authenticity of the player data if you need it.
     
  15. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    Wow, that's a fast forum reply!

    That part makes sense to me, I am planning to run a bot client that does nothing but run the AI, as well as act as a sanity check for basic player movement. I am assuming I can set this as the authoritative client manually or just make sure it is always the first client to connect. Just mulling over in my head how much work it will be to have it also do things like check to see if a player client did something it should not be able to do, ie. run too fast, walk through a wall, etc. Seems like doable checks but just wanted to verify this is something that has to be added and not part of the framework.
     
  16. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Yup, the first client to enter a channel is designated as the authoritative host, and you can transfer the host status yourself.
     
  17. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    So, what the purpose/use of the TNet server? Just to implement a lobby system?
     
  18. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    To forward communication to all clients in the same channel. Think of it as joining a chat room in IRC. Same idea with TNet. You connect to the server, then you join a chat room, and you are able to communicate with everyone in the same chat room. The server can have many chat rooms.
     
  19. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I can't think of where I need the channel to forward to a specific channel. If the players in the same game, connect to me (client), I already can filter the channels here. So it seems more useful in implementing a lobby, no? Perhaps you can add in a framework for that, more than en echo reply.
     
  20. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Channel forward to a specific channel? I think you're misunderstanding something. A game server can have many channels. Each channel is a completely separate game. It doesn't even need to be the same executable, as long as it uses TNet. You can have only one channel on your local server, or you can have 1000 channels on your remote hosted server, it's up to you.
     
  21. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    ok, so your channel is a game instance, But if you cannot run physics on server, so' that's limiting. So in the case, I can only use it for lobby purpose, right?
     
  22. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    A lobby is a room where players meet prior to starting a game. You can have your game join a specific channel when it connects to the server, letting players communicate. When you want to start a game, do so by joining another channel on the same server. Other players who want to join your game can do so by joining your channel.

    There is no need to run physics on the server. Doing so would severely increase the resource and memory usage on the server, and would basically limit the server to a single game instance at a time. Clients already do all the physics calculations. One player is authoritative, and can send out corrections to others -- taking the workload off your server.
     
  23. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    Hi, I am thinking about using Tnet in my game but I am confused as to how I would get the server code running on a web hosting server. I have a host papa server on a pay per month server farm, How would I get the server running on that as I only have cpanel access to the server, and ftp to be able to upload files etc.
     
  24. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Short answer: you can't. Not with a CPanel-based web hosting service. You need a virtual private server (VPS), not a web server.
     
  25. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    I suspected as much, thanks.
     
  26. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    To start of I am a total network noob T.Net.N. :) and I am using UnityScript. So I am searching for an easy solution for my prototypes.

    Firt of all, can TNet work with UnityScript?
    Considering the above, do you honestly recomend me trying Tnet over Photon or Uplay?

    Thanks a lot. I like your assets
     
  27. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    It has been said that TNet is the easiest of the networking libraries to learn, so it's really up to you. And yes, it will work with UnityScript, but you will want to move its scripts to the Plugins folder, similar to NGUI.
     
  28. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    503
    Do you have any intent to ever release a flash update (TCP only of course)? This would be amazing and bring TNet on a new level where it will be competing with SFS2x for instance.
     
  29. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Unity doesn't support sockets in Flash, so there isn't much I can do.
     
  30. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    503
  31. eskimojoe

    eskimojoe

    Joined:
    Jun 4, 2012
    Posts:
    1,440
    @ArenMook,

    I removed my posts about NGUI vs. eDriven comparisons on this thread. It was uncalled for and I am sorry for such behaviour.


    People are advised to take a second look at NGUI and that other GUI solutions have both advantages and disadvantages. One solution is no lesser than other; Each have their own ways of doing things and it is reminded to select the best choice / best solution appropriate to their needs.
     
  32. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    Having just released my Multiplayer component for my game Lunar Flight on Steam I can't recommend using TNet enough, it really is a simple and powerful well thought out framework for adding networking to your game.
     
  33. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    You can or not?! :confused:
     
  34. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    He CAN'T recommend it ENOUGH, it's perfectly clear English there, as in, he couldn't recommend it to the point where it would be enough recommendation.

    "I can't recommend it enough" is a better recommandation than "i can recommend it"
     
  35. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    My bad. I'm French. ;)
    Traduction donc de "Je ne peux que le recommander etc etc...". Merci
     
  36. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    So am i !-_-!
     
  37. danish

    danish

    Joined:
    Dec 27, 2012
    Posts:
    10
    can we connect ios with android device using this plugin or can connect same devices
     
  38. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Yes you can. Starlink uses it and it has been released on PC, Mac, Linux, iOS, and Android -- allowing cross-platform multiplayer.
     
  39. johny

    johny

    Joined:
    Aug 31, 2011
    Posts:
    133
    Hey ArenMook. Is it possible to create server instances at runtime? I would like for people to set up there own server instances that others can join.
     
  40. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    414
    Just purchased, but...

    Using the "Example Menu"
    *extracted TNServer.exe and running it

    Build for web (added example 1,2,3 etc scenes), (set to run in background)
    run it (in browser), try to connect = "Connecting..."
    *Server console shows "has Connected".."has timed out"..."has disconnected"

    Stand Alone Build works fine

    What am I missing about Web version?
    *Web build in editor works
     
  41. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @johny: TNServerInstance.Start(...)

    @bocs: "Run In background" must be checked.
     
  42. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    414
    as I said, I do have "Run In background" checked....

    *Unity 4.1.5f1
    *tested in chrome and IE9

     
  43. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Hmm, you're right, there seems to be some issue with the web player. I'll investigate.
     
  44. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Alright, 1.7.2b has the fix.
     
  45. bravery

    bravery

    Joined:
    Mar 26, 2009
    Posts:
    270
    Hello Aren,

    Can I use TNet to create a lobby, where player can do multiplayer against each-other?

    Also can I have an invite a friend feature to invite a friend for mulitplayer game?
     
  46. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Lobby is where people meet, not play against each other. Can you create a lobby for players to meet? Certainly. Just join a specific channel (such as "1"). Can you invite friends? Also -- certainly. You can send private messages directly to players, assuming they are connected to the same server.
     
  47. kys01212

    kys01212

    Joined:
    Jun 20, 2011
    Posts:
    14
    Hi Aren,

    Is there a limit to the number of connections the server can handle? say. . . I would like to create a huge lobby where thousands could join, would that be possible?

    From the forums I read that Unity's built-in networking could only handle 100-120 connections.

    Thanks,

    Kevin
     
  48. Psoeter

    Psoeter

    Joined:
    Jul 16, 2013
    Posts:
    1
    Also interested, Hopefully its dependent on the server hardware and not a user cap hard-coded or anything.
     
  49. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I've answered this question a few times on the support forum already. There is no limit within TNet, so it all depends on your hardware, the operating system, and how much bandwidth you're using versus how much bandwidth you have.
     
  50. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hiya,

    I'm very interested in tentatively learning multiplayer and I like the look of this. It looks engaging and simple for an old git like me. I was hoping you could clarify some of the confusion I have:

    1. Do I need to be running a server at all?

    2. If the game is on an android console, or mobile phone, is that phone supposed to be running a server ? very confused about the purpose of the server.

    3. The games I intend to make multiplayer will be initially a platform game where players co-operatively play on mobile phones. Could you give me a small list of tasks ie: 1. you need a pc running on the web with server code or it won't work... blah?

    4. I'd be using it for a relatively fast paced action game, but not an FPS. However players will be moving quite quickly. Is this still OK?

    Sorry if these are answered, I did read the docs and such on your site, but I'm still a little confused about the specific role of the server, and if a mobile phone should be hosting a server for the simple peer to peer co op gameplay I have in mind.

    Thanks!