Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: ArenMook on December 10, 2012, 05:16:55 PM

Title: TNet: Tasharen Networking Framework
Post by: ArenMook on December 10, 2012, 05:16:55 PM
Almost exactly a year ago I decided to make a game and wrote a UI system for it, releasing it on the Asset Store almost as an afterthought. You may know this system as NGUI -- it turned out to be fairly popular. People liked its simplicity, design, and well-commented, elegant code.

Although NGUI has halted the game's development for a short while, I did persevere, and six months ago I started working on adding multi-player functionality to that game. I tried out 3 of the top solutions, but ultimately was not happy with either. I ended up just sticking with one of them due to time constraints, but never stopped wishing that I could write my own, applying all that I've learned from my development of NGUI -- the simplicity, power, flexibility, and well-thought out, open code.

A few weeks ago I decided to do just that and started on a new project, called Tasharen Networking Framework, or "TNet" for short. This project is now ready to be released.

So what does it offer?
There are more features... but I've rambled long enough. Here is some basic usage information.

Q: How to start and stop a server from in-game?
  1. TNServerInstance.Start(port, [fileToLoad]);
  2. TNServerInstance.Stop([fileToSave]]);
Q: How to connect/disconnect?
  1. TNManager.Connect(address);
  2. TNManager.Disconnect();
Q: How to join/leave a channel?
  1. TNManager.JoinChannel(id, levelToLoad);
  2. TNManager.LeaveChannel();
Q: How to instantiate new objects and then destroy them?
  1. TNManager.Create(gameObject, position, rotation);
  2. TNManager.Destroy(gameObject);
Q: How to send a remote function call?
  1. TNObject tno = GetComponent<TNObject>(); // You can skip this line if you derived your script from TNBehaviour
  2. tno.Send("FunctionName", target, <parameters>);
Q: What built-in notifications are there?
  1. OnNetworkConnect (success, error);
  2. OnNetworkDisconnect()
  3. OnNetworkJoinChannel (success, error)
  4. OnNetworkLeaveChannel()
  5. OnNetworkPlayerJoin (player)
  6. OnNetworkPlayerLeave (player)
  7. OnNetworkPlayerRenamed (player, previousName)
  8. OnNetworkError (error)
Q: What examples are there?
See for yourself:
Title: Re: TNet: Tasharen Networking Framework
Post by: aidji on December 11, 2012, 12:02:44 AM
Hi it look promising, when we switch map its save everything, but its there an option to save server when we switch it off?

its will have some inspector view option like ngui or its only full code?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 11, 2012, 05:17:48 AM
When you create a channel you specify whether you want it to be persistent or not. Even if you create it as a persistent channel you can close it later. Closing it prevents players from joining (but will let the current players play normally). It will also prevent data from saving, and when the last player leaves the channel will be removed, discarding its data.
Title: Re: TNet: Tasharen Networking Framework
Post by: Cripple on December 11, 2012, 09:56:21 AM
Hi,

I'm working on a game which will need some network, I might use your network framework for it :)

How much will it cost ?

Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 11, 2012, 09:57:15 AM
Probably $45 initially. Fairly cheap.
Title: Re: TNet: Tasharen Networking Framework
Post by: Cripple on December 11, 2012, 10:13:41 AM
Any ETA ? :P
Does the license will be the same as NGUI (1 license for 1 company or 1 license per user) and do you plan to release a free version to test it before buying it ?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 11, 2012, 10:17:54 AM
Yeah I can probably create a free version later. It would be a lot easier to do than with NGUI. ETA-wise... a few days. I have to create some graphics for the asset store. Out-of-code documentation pages and a video would be helpful as well.

License-wise, I am thinking the most logical approach would be one license per project that uses it.
Title: Re: TNet: Tasharen Networking Framework
Post by: SketchWork on December 11, 2012, 07:20:15 PM
I'm very interested.  I have a few questions if that's ok.

1)  What client platforms will it support?

2)  What server platforms does it require?

3)  How do the clients communicate with the server?  Internet, Bluetooth, WiFi, local wired network, combination of the above?

I'm needing a client/server solutions to run on an offline private network iOS and Win/Mac server - would this work?

Thanks ArenMook :)
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 11, 2012, 11:29:34 PM
1) Everything Unity can run on and some things it can't. It can run from within Unity, and by compiling it via C# directly (in case of the server).

2) Same as above -- you can start a local server on a separate thread right from within Unity via TNServerInstance.Start(), or you can compile an executable for the platform of your choice using the C# or Mono compiler. Windows executable is around 20 kb, for example. It's very lightweight.

3) Via UDP broadcasts and TCP connections. This means anything connected to the same wired or wireless network or internet.

It most certainly will. You don't need internet to communicate. Nah0y from these forum got an early copy and was able to easily create a solution for his game where the first player to start the iOS game launches the server, and other players automatically join it without having to enter any IP addresses. This is done by having the first player broadcast a request asking for a server to the entire network. When a response arrives, join that server. If no response comes within X amount of time, start a new server.
Title: Re: TNet: Tasharen Networking Framework
Post by: SketchWork on December 12, 2012, 05:28:33 AM
Awesome!  I'm sold - were do I sign :)

This is for a "serious game" that is already up and running, but the client wants me to introduce a networking element to it.  I was going to write it myself, but this looks like exactly what I was after.  Did you say there was a beta you have that I could run some tests with?  Also, what would the maximum number of recommended clients for TNet before it has a heart attack and dies?

Last thing, Unity Free or Pro or both?

Thanks again.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 12, 2012, 07:43:39 AM
There is indeed a private beta. The number of clients for TNet is pretty much limited by your bandwidth. IO completion port approach makes it pretty scaleable. What kind of a game is it? TNet is better for some things than others. It's ideal for iOS/Android/PC/Mac/Linux devices that want to just connect to each other (if they are on the same network). It may be less ideal for other things (FPS requiring security for example).
Title: Re: TNet: Tasharen Networking Framework
Post by: SketchWork on December 12, 2012, 08:56:14 AM
It is for linking different machines together on the same network and looking at the demo it will work perfectly.  Would it be possible to have a test with the beta version?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 12, 2012, 10:04:33 AM
If you want to try it out, add me to skype (arenmook). Note that I will need to know your invoice # for NGUI though (if you bought it via asset store), or your email for a direct purchase of NGUI.
Title: Re: TNet: Tasharen Networking Framework
Post by: SketchWork on December 12, 2012, 10:42:13 AM
No problem.  Sent you a Skype request for a message containing my Order number for NGUI.

Thanks again,

Justin.
Title: Re: TNet: Tasharen Networking Framework
Post by: AntiAction on December 13, 2012, 02:17:10 PM

Tasharen Networking is awesome!  I ported our single player game to the TNet in less than one hour!  --- and I did it while sipping coffee in one hand and watching a movie!!  I wasn't even fully focused :)

I've tried Photon and uLink.  Both of those solutions demand much more time, energy and cognitive load to get even the simplest cases working.  We now have multiplayer battling happening without any heavy revisions of our game's architecture or deep diving through APIs.

I won't go on & on fantasticating about how great our experience has been.  In a nutshell, ArenMook | Tasharen has done it again.  Much like NGUI did for Unity GUIs, Tasharen Networking is an elegance of code, smart and a productivity accelerator.
Title: Re: TNet: Tasharen Networking Framework
Post by: SketchWork on December 14, 2012, 11:29:01 AM
Same here.

This product is so easy to integrate and gives awesome results in very little time.
Title: Re: TNet: Tasharen Networking Framework
Post by: Martin Schultz on December 18, 2012, 02:44:11 AM
My first tests are like "wow". Easiest network library I've used so far. The NGUI for networking libraries. Insta buy as soon as it is on the Asset Store.
Title: Re: TNet: Tasharen Networking Framework
Post by: Cripple on December 18, 2012, 11:13:29 AM
Is it possible to get an early access to the beta ?

I have a NGUI license.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 18, 2012, 11:49:02 AM
Add me to skype (arenmook) and let me know your invoice # as well as your unity forum name, and sure.
Title: Re: TNet: Tasharen Networking Framework
Post by: SpheredCazual on December 18, 2012, 01:22:23 PM
Any Idea yet when this will be available?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 18, 2012, 01:24:16 PM
Likely this Sunday.
Title: TNet: Tasharen Networking Framework
Post by: gamesonytablet on December 20, 2012, 08:49:52 AM
TNet seems so well thought through!

We're all waiting in Japan for the release, ArenMook. ::) I posted a translation of this topic on my blog, and already have 400+ accesses in the past 12 hours. On top of that, there were lots of  Favorited Tweets and RT about TNet as well.

Just waitin' for the next great news on this  ;D
Title: Re: TNet: Tasharen Networking Framework
Post by: ahgElliot on December 20, 2012, 10:28:17 PM
For a $45 price point I will gladly pay you.  This looks great!  I love NGUI and you are by far the best supporter of your assets.  I can't wait for it to come out in a few days!  :D
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 23, 2012, 07:07:10 AM
I'm... almost.... ready to release it. Just working out one last kink, then I'll get video-happy.
Title: Re: TNet: Tasharen Networking Framework
Post by: Martin Schultz on December 23, 2012, 07:21:02 AM
Credit card ready to pay... :-)
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 23, 2012, 02:19:55 PM
http://www.youtube.com/watch?v=l3H45JXJShY
Title: Re: TNet: Tasharen Networking Framework
Post by: Martin Schultz on December 23, 2012, 04:10:30 PM
Great video. While watching a feature idea came out - be able to have buffered calls and not only the last for a function. So if you want to build a state for the game, like what upgrades a player received, save this to the buffer and when a new player connects, he receives all the updates for that player from the server to synchronize the state.

Any idea about the release date now? :-)
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 23, 2012, 04:34:13 PM
It's best to RFC the "latest set" of everything, not individual things. So in your case, simply RFC the "SetUpgrades" function with a string containing the numbers indicating upgraded state. For example "0012050".

TNet: Now with documentation -- http://www.tasharen.com/?page_id=4518
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 23, 2012, 06:19:35 PM
Alright, all done. Asset Store is pending review, direct PayPal purchase is up on the website, and professional edition is optional per-request.
Title: Re: TNet: Tasharen Networking Framework
Post by: mishaps on December 24, 2012, 03:57:38 PM
Multiplayer by the NGUI dude? I'm in!
Sounds perfect for local wi-fi multiplayer. With Photon Cloud I get a lobby and a list of games around the world waiting for players. I can join one of them randomly. Can I do this easily with TNet right now? Or will there be a TNet Cloud?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 24, 2012, 04:00:50 PM
You can put up a stand-alone TNet server somewhere accessible, and then those who join it can query a list of open channels. Same idea. I have a TNet server running on an Amazon Cloud EC2 for example. It's a 35 kb executable that uses just about no resources.
Title: Re: TNet: Tasharen Networking Framework
Post by: mishaps on December 24, 2012, 04:06:10 PM
so its doable, awesome!
I think Photon Cloud is marketed towards people like me who don't know much about setting up servers themselves! Perhaps I missed it but do you have a tutorial or something for newbies on how to setup a TNet server? Is it some extra file I get with the package off the asset store and upload to a server or something?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 24, 2012, 04:09:39 PM
The server comes with TNet in a zip file. I compiled a windows executable, and there is a solution and project that you can open on a mac and compile it there. Likewise if you have a C# compiler set up on Linux, you can compile it there as well.

To host it somewhere, simply run the executable.
Title: Re: TNet: Tasharen Networking Framework
Post by: mishaps on December 24, 2012, 04:21:49 PM
thanks man. I just bought it. Sounds easy but I'm not too familiar with running executables on servers. I'll look into it.
Is there a tutorial or video or something step-by-step how to setup the server with a lobby like photon cloud? IMHO you'd pull across a lot of customers if you made this global networking sorta thing really straight-forward. I'd also happily pay if you provided a service like photon cloud.  8)
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 24, 2012, 04:39:24 PM
A server is just like any other computer. You just remote desktop into it (in case of Amazon this means double-clicking on a downloadable file), which opens up a (in my case) windows login dialog. I log in, and I am able to use the remote computer as if I was sitting right in front of it, including downloading stuff and running executables. :)

I could certainly host a cloud-based service if there is enough demand for it. I'm sure Photon guys themselves could do that too since to them it would be just running an executable on one of their cloud servers just like with Photon. ;)
Title: Re: TNet: Tasharen Networking Framework
Post by: mishaps on December 24, 2012, 04:54:10 PM
Thanks man I'm looking into the amazon thing right now :)

I suppose what I meant was with photon cloud there was no "scary server stuff" to setup first - one less roadblock for a newbie. I'm sure once I understand the server thing I'll be like "duh that was easy". Frankly I'm having trouble with photon it keeping crashing on multiple games and I'd rather use something by the "NGUI dude" anyway.  8)
Title: Re: TNet: Tasharen Networking Framework
Post by: nah0y on December 24, 2012, 04:58:38 PM
I the meantime you could launch the executable on your computer and run some tests just connecting to localhost !
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 24, 2012, 05:05:08 PM
I the meantime you could launch the executable on your computer and run some tests just connecting to localhost !
Yup. Or just hit the "host" button from the example menu. It's really easy to get started. Putting your game server on a cloud is generally the last step :)
Title: Re: TNet: Tasharen Networking Framework
Post by: mishaps on December 24, 2012, 05:09:11 PM
very cool :)

even better also include mac compile of the server for iOS devs! prob super easy to compile myself once i work it out and all but again one less roadblock blah blah
Title: Re: TNet: Tasharen Networking Framework
Post by: mishaps on December 24, 2012, 05:35:00 PM
thanks for releasing this anyhoo. great present for xmas day!
Title: Re: TNet: Tasharen Networking Framework
Post by: devfo on December 24, 2012, 11:58:14 PM
Sounds exacty like what I have been looking for. I would need to run this on my own server along with database interaction. Would you reccomment running a Linux or Windows server?
The server example you provide with the package -- I am guessing it's Windows?
Title: Re: TNet: Tasharen Networking Framework
Post by: Martin Schultz on December 25, 2012, 02:01:54 AM
First of all, merry christmas all! :-)

One question regarding the licensing that holds me back so far from buying: It says "per project". Do I need to license one TNet per project?
Title: Re: TNet: Tasharen Networking Framework
Post by: mishaps on December 25, 2012, 02:07:07 AM
I think its per-studio? On this page it says per-studio near the bottom. http://www.tasharen.com/?page_id=4518 (http://www.tasharen.com/?page_id=4518)
Title: Re: TNet: Tasharen Networking Framework
Post by: Martin Schultz on December 25, 2012, 02:59:38 AM
Ah ok, that would make sense. I thought already it's hard to achieve that licensing with the Asset Store - I can only purchase once.

Btw, it's available in the Asset Store! Just purchased it from there!
Title: Re: TNet: Tasharen Networking Framework
Post by: mishaps on December 25, 2012, 03:46:13 AM
Cool I got the server that comes with the package running on my mac, yay! Just gotta download the mono framework then open terminal and type " mono <file location>/TNServer.exe". You can get the file location by selecting it in the finder, pressing CMD+C then pasting in terminal.

Hey how could I do something like photon's JoinRandomRoom()? I also want to limit a game to max 2 players, how could I do this?
Thanks in advance!
Title: Re: TNet: Tasharen Networking Framework
Post by: Cripple on December 25, 2012, 06:26:06 AM
I recommand this ... just buy it, it is an awesome framework. I got an access of the beta and I am going to buy it eyes closed.

The code is really clear and well documented. The example are good and there is all you need to know to port your game to multiplayer.

Great work :)
Title: Re: TNet: Tasharen Networking Framework
Post by: mishaps on December 25, 2012, 06:34:45 AM
Already got it just trying to port my game! I think I found enough to do it in the tips page u can send a packet to request a channel list and ditto for closing off a channel. Now if I can just get the scary server stuff up and running I'm good to go ahead with it heh heh.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 25, 2012, 09:35:51 AM
Windows vs Linux -- I believe IO completion ports are only supported on Windows, which would suggest better performance there... but Linux is generally better for running servers of any kind. In the end, I think it'll be about preference -- what you prefer to use.

JoinRandomRoom -- you can request a list of open channels from the server, then just pick a random one and join it. :)

You can also compile the server's C# files natively by extracting the ZIP's contents into the root of your project, then opening the server project with MonoDevelop.

Alternatively, you can create a new C# project from scratch by including these files:

Assets/TNet/Common/*
Assets/TNet/Server/*
TNetTest/Servermain.cs (extracted from the zip file)
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 29, 2012, 06:04:56 AM
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.
Title: Re: TNet: Tasharen Networking Framework
Post by: bilbo0s on December 29, 2012, 02:10:03 PM
After looking through the documentation, I have to say that this seems like a VERY simple yet powerful package. It looks like you have successfully created another needed middleware component for Unity.

I do have a question about the server however. I was trying to ascertain whether or not the server itself could start channels that would exist BEFORE the clients connect to them? One thing Photon and uLink allow is for several "Rooms" to be fired up by the server and then people can come and go as they please. It seems in Tasharen, the CLIENT is the one who starts a channel, and other clients connect to it. If the hosting client leaves the channel, the channel is destroyed? or is another client elected to be the host? or does the entire channel just go away?

Even if this doesn't suit all purposes, it really is a GREAT option for a lot of people. You are to be congratulated for making it.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on December 29, 2012, 03:11:46 PM
If a client leaves the channel, another is automatically designated to be a host (authoritative player). The channel doesn't go anywhere. You can also make it so that even if the last player leaves, the channel still remains with all the remote function calls remaining for the next player that joins.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 01, 2013, 10:46:55 PM
Hello, I'm curious.. how is the game state saved when all players disconnect?

Is a file written to disk? Is something sent to a database? Is it all stored in memory?

And can we control the way this data is saved/retrieved?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 01, 2013, 10:53:57 PM
After the last player leaves, the state will be in memory. When the server shuts down, the state gets saved to the disk. When the server starts, the state is not loaded until after the channel is re-created.

You can specify whether you want this kind of behaviour when you create the channel, and you can also close the channel at any time (which will prevent the state from being saved as well).
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 01, 2013, 11:07:34 PM
Thanks ArenMook!

Maybe you can tell me if TNFramework is right for my needs. I'm re-creating a 3D farmville type game.. so each farm will be a channel, and other users can visit other player's farms.

There could be 100's-1000's of farms being played at a time... and 10,000's of users who have farms. Will TNFramework be able to handle all of that? and is there a way to expand across multiple servers if there are too many channels?

Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 01, 2013, 11:12:31 PM
It's really up to how beefy your server is going to be. TNet is fairly efficient in how it handles everything. You can have one central server where players log in and request a list of known servers, then disconnect and join an actual game server if one server can't handle everything.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 02, 2013, 12:19:42 PM
Aren this has been a big help and I'm do believe I'll be purchasing this product next week.

One last thing however.... can I run this as a headless server? I want to use Amazone EC2 and launch a few of these servers.

Is that even possible? Thanks again for all your hard work!
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 02, 2013, 12:24:01 PM
Yes, the server is always headless. That's why it's only a 35 kb executable.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 03, 2013, 01:25:34 AM
Wow, this is a really great package! Thanks for all the help.

If I were to give any feature requests (as for optimization).. I would suggest an area of interest feature. Basically if there are hundreds of characters or objects moving in the scene, only the characters/objects within a certain range of the player will be received by the player.

So if a cube is moving on the other side of the scene, the packets from that cube will only be sent to players near it.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 03, 2013, 01:37:52 AM
That's one of those game-specific features. Fortunately the code should be easy to follow and modify. ;)
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 03, 2013, 02:21:18 PM
- sorry for flooding you with questions.

But I was just reviewing the documentation and it says that I need to add the TNManager to the start of my game (the first scene) and add any objects that I plan to instantiate.

But what if the user can play the game totally single player and only do networking if they go under a certain sub menu? Can I add TNManager later in the game (in the sub menu)?

And can I remove a TNManager and add it again with different set of objects (for other scenes) ?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 03, 2013, 02:22:19 PM
Yeah you can add it later. As long as it's there when you are trying to start a multi-player game, you're fine.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 04, 2013, 12:53:30 PM
Loving TNet Framework so far!

One issue I'm having is when a user shuts down the game without logging out of the channel.

I'm creating a box in the scene using TNManager.Create() and when OnNetworkPlayerLeave each box in the scene checks to see if the player that left was the one that owned it. If the player that left owned that box, then it uses TNManager.Destroy() on itself.

This works fine.. however when the last player forces the game to close.. there's no client to remove the box, and it sticks around and never removed.

How can I handle things like that?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 04, 2013, 12:59:23 PM
When you join a channel, specify a 'false' for the "persistent" parameter.
Title: Re: TNet: Tasharen Networking Framework
Post by: MattCarr on January 05, 2013, 01:48:50 AM
Great package. I was going to write my own networking framework for the game we're making soon, but I saw this and the quality of it's design and code and thought I'd save myself the time :).

I've only been using it for a few hours so far and will probably have more suggestions and find more issues later, but so far I have these:


Thanks again for making this package. I spent 3 years working on a large networked simulation project in Unity and produced for that something of a very similar design, but didn't end up as clean and easy to integrate into general multiplayer projects (mine was primarily for cluster rendering on multi-machine driven displays).

Edit:

Found what seems like another issue: Creating AutoSync objects at runtime won't work properly as their mCanSync value will not be set to true. I've fixed for now in my project with
  1. if (TNManager.isConnected)
  2. {
  3.    mCanSync = true;
  4. }
In Awake().
Title: Re: TNet: Tasharen Networking Framework
Post by: fgame on January 05, 2013, 06:06:13 AM
What I want to know most is how does it compare to the main existing networking solutions? E.g. Photon, uLink and so.
You know, those are Fxxx expensive, and yours is so cheap compared to them.

I always hate Photon, uLink this kind of stuff, they are even more expensive than Unity itself! WTF. I really hope you can finish them off and make them jobless.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 05, 2013, 07:03:31 AM
@MattCarr:
1. OnCreateObject setting mObjectOwner does indeed seem like something that shouldn't be there. It's harmless as generally you will...
2. ...set the object's logic in its Awake() script. This is when you should determine who the object belongs to. There is no need for an OnCreate() function. And Awake() gets called right after Instantiate.
3. You can still append to them afterwards with +=, can't you? This happens in Awake(), meaning as soon as TNManager is created -- so you wouldn't be setting anything before that.

Regarding AutoSync: there is no need to sync anything unless you're actually in a channel playing multi-player, in which case you will get the OnNetworkJoinChannel callback.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 05, 2013, 07:07:09 AM
What I want to know most is how does it compare to the main existing networking solutions? E.g. Photon, uLink and so.
You know, those are Fxxx expensive, and yours is so cheap compared to them.

I always hate Photon, uLink this kind of stuff, they are even more expensive than Unity itself! WTF. I really hope you can finish them off and make them jobless.
Just different packages. TNet focuses on simplicity of use and elegance of code. It aims to accomplish more with far less code, which generally makes it much easier to work with. I don't want to make anyone jobless... all packages have their use to the right person. :)
Title: Re: TNet: Tasharen Networking Framework
Post by: MattCarr on January 05, 2013, 07:20:35 AM
2. ...set the object's logic in its Awake() script. This is when you should determine who the object belongs to. There is no need for an OnCreate() function. And Awake() gets called right after Instantiate.
Ok, yeah. I didn't see the objectOwnerID property (EDIT: or isThisMyObject :) ) so didn't understand your usage of mObjectOwner.

3. You can still append to them afterwards with +=, can't you? This happens in Awake(), meaning as soon as TNManager is created -- so you wouldn't be setting anything before that.
Yeah, but my point was more that there's no reason to not use += in TNManager to remove the current limitation of not being able add callbacks in earlier Awake() methods. Awake is generally where I prefer to assign callbacks.

Regarding AutoSync: there is no need to sync anything unless you're actually in a channel playing multi-player, in which case you will get the OnNetworkJoinChannel callback.
No, I'm talking about AutoSync's being created at runtime. So the host instantiates one, it's default mCanSync value is false and OnNetworkJoinChannel is not called because it has already been joined. For this instance the AutoSync should be checking whether or not it's already in a channel in its init so it can set mCanSync to true.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 05, 2013, 07:28:41 AM
Ah, good point about AutoSync. I've fixed it like so:
  1.                                 // Only start the coroutine if we wanted to run periodic updates
  2.                                 if (updatesPerSecond > 0 && TNManager.isConnected)
  3.                                 {
  4.                                         // If we're already in a channel, we can now sync this object
  5.                                         if (TNManager.isInChannel) mCanSync = true;
  6.                                         StartCoroutine(PeriodicSync());
  7.                                 }
  8.                                 else enabled = false;
I'll change it to +=, but any reason you don't want to just rely on automatic OnNetwork* series of functions?
Title: Re: TNet: Tasharen Networking Framework
Post by: MattCarr on January 05, 2013, 07:40:10 AM
I'll change it to +=, but any reason you don't want to just rely on automatic OnNetwork* series of functions?

Thanks. No reason at the moment, I'm actually not adding any callbacks to those right now and possibly never would, it was just something I noticed and thought I'd raise just in case it ever came up in the future. Not a big deal :).
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 05, 2013, 07:48:27 AM
Well, one thing I don't like doing is changes for the sake of changes. :P
Title: Re: TNet: Tasharen Networking Framework
Post by: MattCarr on January 05, 2013, 08:37:05 AM
Well, one thing I don't like doing is changes for the sake of changes. :P
Sure. It was just a suggestion so it's up to you whether or not you incorporate it into the next version. I don't see an issue with simple changes that have upsides and no down sides though.

It seems like the player is not set as the host properly after joining a channel until other players have joined and told them they're the host? In TcpPlayer.FinishJoiningChannel there is a check for if the channel host is null and if so it sets the host to the player. Then in either case a packet is sent to other players informing them of who the host is. If you create a server and join a channel, you're set as the channel host but you don't receive the sent packet so the other host/isHosting values don't appear to be set until someone else joins and sends that packet back to the host. Is this the case or have I missed something? Can be tested by starting a server, joining a channel and checking the TNManager.isHosting value before and after a client joins.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 05, 2013, 08:42:09 AM
TNTcpPlayer, line 60. There is always a host. You can't join a channel without getting that notification. This packet is sent to the player. I suggest you use the package, and post if you actually run into issues. Pre-emptive posting won't be helpful much. I am actually making a game with TNet powering its networking right now, and so far it's working flawlessly.
Title: Re: TNet: Tasharen Networking Framework
Post by: MattCarr on January 05, 2013, 08:47:47 AM
TNTcpPlayer, line 60. There is always a host. You can't join a channel without getting that notification.
Yeah, but there is still the issue of TNManager.isHosting returning false still occurs in that instance. Just checked again to see why and it's because GameClient.isHosting checks if players.size > 0 and the host is not added to that list so it is 0 until someone else joins. Is there a reason for that condition? I would think isHosting should return true when the player is the host and no clients are connected.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 05, 2013, 08:51:41 AM
Oh that. Right, I fixed that about a week ago on my end. I'll go live as a part of 1.2 later today.
Title: Re: TNet: Tasharen Networking Framework
Post by: MattCarr on January 05, 2013, 09:10:51 AM
I suggest you use the package, and post if you actually run into issues. Pre-emptive posting won't be helpful much. I am actually making a game with TNet powering its networking right now, and so far it's working flawlessly.
Sorry, I don't intend to harass you with these posts, but if you'd bothered to look into it fully you would have seen there was an issue for which I've pointed out what seems to be the cause in my above post.

Personally, I never buy Asset Store packages because I'd almost always rather code the functionality myself. In this case I was impressed with the quality of the codebase so I made an exception. I understand your negative reaction to my posts based on what must be the norm from repeated posts with questions from the average user that purchase your products, but I'd appreciate it if you resisted the urge in my case because I am not the average user, I want to use this and don't just want to make many modifications to the source for obvious reasons. So when I find issues I'd expect you'd like me to let you know, but let me know if you'd rather I didn't. Finally, I'll just say that pointing out you're using it on your project without issue isn't an overly meaningful point when you're releasing a generic solution that will no doubt be used quite differently in many cases than your projects implementation.

Please don't take the above too negatively. I was just a little annoyed by your response when I have been taking the time to inform you asap of issues I found since this is a new product. I have probably reacted equally negatively towards users of my products. I'm just not used to being dismissed :).

And I do very much like this product. It's excellent and the issues are few. If there were lots of issues then trust me, I wouldn't be bothering to post here at all ;).
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 05, 2013, 09:13:20 AM
Nah, please accept my apologies actually. I totally forgot that I fixed something related to that. I should have pushed an update out then and there instead of waiting for the weekend. :)
Title: Re: TNet: Tasharen Networking Framework
Post by: MattCarr on January 05, 2013, 09:28:44 AM
Nah, please accept my apologies actually. I totally forgot that I fixed something related to that. I should have pushed an update out then and there instead of waiting for the weekend. :)

It's all good :). Your success with NGUI is actually quite inspirational and I'm thankful for it. About 6 months ago I left my lead programmer job to, like you, do full time indie development. In that time I've found motivation to be the most precious commodity and I find nothing more motivating that seeing other successful indies :).
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 05, 2013, 09:33:22 AM
Well then you should definitely go to IGF in March. ;)
Title: Re: TNet: Tasharen Networking Framework
Post by: MattCarr on January 05, 2013, 09:49:50 AM
Well then you should definitely go to IGF in March. ;)

I'd love to but unfortunately I'm an Australian :-\. Worse still I'm actually in America for a few weeks in March and leave on the day IGF starts. At least we have PAX Australia this year and if nothing else my mate's game Lunar Flight (http://store.steampowered.com/app/208600) (Steam key PMed to you) which I did some work on will have a booth, but I'm quietly hoping the Indie Showcase submissions are far enough away that my game is ready to submit for consideration because it'll definitely be ready to show come PAX time.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 05, 2013, 11:08:24 AM
1.2.0
- NEW: Added TNManager.CloseChannel.
- FIX: TNManager.isHosting was not correct if the host was alone.
- FIX: TNAutoSync will now start properly on runtime-instantiated objects.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 06, 2013, 01:50:25 PM
Hi Aren!

Is there any data/packet encryption going on when data is being sent to the server? If not, is it possible that in the future that could be a feature or option!?  :D
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 06, 2013, 02:02:42 PM
No encryption. Encryption is something that should be done by the developer, as using standard encryption methods would result in VERY bad performance. Best packet "encryption" would be bit shifting of data or something similar that would have little effect on performance, but would make the data more difficult to read.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 06, 2013, 02:07:16 PM
awesome! thanks for the tip!
Title: Re: TNet: Tasharen Networking Framework
Post by: Detocroix on January 07, 2013, 08:09:26 AM
A small question,

When you're using TNManager.Create(), you can't assign the outcome to a variable or am I doing it wrong?

GameObject CurrentPlayer;
CurrentPlayer = TNManager.Create(PlayerObject, SpawnPosition, Quaternion.identity) as GameObject;

Results in error "Cannot convert type 'void' to 'UnityEngine.GameObject' via a built-in conversion"
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 07, 2013, 09:04:28 AM
TNManager.Create does not give you a return value. The object creation is delayed, as it happens on all remote computers. If you need to set additional parameters, you need to do so via an RFC call so it's properly synchronzied.
Title: Re: TNet: Tasharen Networking Framework
Post by: devfo on January 07, 2013, 01:00:08 PM
Ok, I just purchased it. Will give feedback once I have a good understanding of it
Title: Re: TNet: Tasharen Networking Framework
Post by: joboldo on January 10, 2013, 05:05:19 PM
Hey,

I have some questions:

1. Is it possible to let 4 random players play together without knowing the channelname etc ? Just hit play, waiting for other random players and then automatically start the game? Similar to Draw Something

2. Is it possible that users have first login to Facebook (with Facebook Connect) to play the game?

Thanks,

Jo
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 10, 2013, 05:07:29 PM
You can request a list of channels from the server and join one of them. Next update will also add the "join random channel" command so this won't be necessary.

Facebook connect logic would be game-specific, as it's not related to networking. You can do your authentication, and if it's successful, proceed to the connect to server step.
Title: Re: TNet: Tasharen Networking Framework
Post by: joboldo on January 10, 2013, 05:19:25 PM
Thanks :)

Some further questions:

1) It's also possible to save the name of the player,his score etc without typing the name of the player again in every new game?

2) If everybody joins randomly after hitting the play button, who will be the host?

3) Do you will make some tutorial for setting up and handling the server? What happens if you have a loooot of players? (over 1 Million?)
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 10, 2013, 05:54:01 PM
1) UIInputSaved is what I use (an NGUI class for input) -- it saves the value for next time. It's not a network-question ;)

2) The first person. Keep in mind "host" means "authoritative player", not "server".

3) A single server cannot have more sockets open than 65535, and everything under 1000 is reserved for "important" programs. Realistically you should spawn new servers once you exceed a certain limit. I don't think I've seen game servers maintain more than 2500 simultaneous connections each. This is why most games use server farms.

As far as setting up a server... just run the executable on a computer of your choice. Or don't -- and just start a server from within Unity on the players' machine.
Title: Re: TNet: Tasharen Networking Framework
Post by: joboldo on January 10, 2013, 08:25:00 PM
thank you :) Great Customer Service.

3 more question:

1. Let's say I'll run my server on an Amazon Cloud Server (running TNet .exe there). All updates (positions etc) will be send to the authoritative player. If he leaves the game a new random authoritative player will be chosen and the updates will be automatically send to the new authoritative player?

2. Spawning new servers will be handled by Amazon or I'm responsible for that? If yes where exactly should I put the code for spawning new servers?

3. Can a player switch between devices(Android or iPhone) with his account (I guess properties like name, character have to be saved in a database? Or is it possible to save it on the server?) to play a game?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 10, 2013, 08:30:17 PM
1. Yup. The game keeps going as if nothing has happened.

2. You can create more TNServer.exe instances by running them on different machines, but how will your players know which one to connect to? You will want some kind of a lobby server for them to connect to, where you will have some load balancing logic that will tell them where to connect next.

3. You can save stuff on the server, but keep in mind that it's going to be accessible by anyone. Ie: if one player saves "pr0n.jpg", others can load it by requesting "pr0n.jpg" -- of course if you don't expose the ability to load random stuff to clients, and restrict it to say, player account ID, then all is well, and you can safely store player-specific info on the server by using their ID as the file name.
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 11, 2013, 12:13:37 PM
Hi Aren !
First of all, congratulations for this incredible work, I'm flabbergasted !

Before exposing my questions and problems, let me introduce myself .
As a student, I am supposed to make a MMO-like running on Android device this year. It's not supposed to be played by billions of players, but it has to be live and working as a proof of concept... The thing is that I haven't a big programmer background (seriously I'm just a scripter... I do my best to get better but there are still topics I'm not good at ... ).

Basically what I want is a non-local network, as it is running on Android device.
Is the TnetServer.zip you're talking about in earlier posts the solution?
If so, what I've understood so far is that I just have to launch the EXE (contained in the zip file ...) on any computer running with windows ?

Can I build a stand-alone version - different from the builds given to the players - including a "GodManager"-like object dealing with every player's persisten data ? (or should those datas - mostly player's account/progression - be stored on his device with the playerPrefs class ?).

To sum-up, my question is : Can a computer be used as a server hosting (with Tnet), and android devices connect to this server using 3G network (non-local network, as an extent : computers running the same built game) ?
Am I getting wrong by thinking that Tnet would be the solution to this ? Would it be the appropriate tool for this project ? Any other solution ?

Well... Sorry for this wall text, but I need to be reassured concerning Tnet and what I've understood by reading this thread.
If Tnet is the solution (by doing what I've just said concerning the TnetServer EXE file thingy), could you repeat step by step the process of setting up such a thing ?

Thank you so much for you time, I'll buythis plugin for personal projects anyway lol, but I'd appreciate an answer concerning the issue raised my student project.
Best regards !

EDIT : Should have red my post one more time before posting xD (misspelling...)
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 11, 2013, 12:52:49 PM
That's how it works, yes. Run TNetServer.exe on any computer (doesn't need to be windows... it's mono, so it'll run on mac and linux just fine), then have your clients connect to that computer.

You can even run it on your Android device, if you like. I had a server running on my phone for the fun of it.
Title: Re: TNet: Tasharen Networking Framework
Post by: devfo on January 11, 2013, 01:02:21 PM
Yarashiel:
I am sure Aren can answer you more specific, but Yes to your questions. I am currently working on and Android app, similiar to what you explained. You can build a stand alone version by using the basic TNet server files -- search earlier posts in this topic and you will find them. I was watching this forum for about a week before i purchased the TNET. Then I was absolutely amazed (well not really, I own NGUI and so I know it will be clean code) how detailed and easy it was to set up.
For my first test I spun up an amazon EC2 instance (Windows server 2012 Base), dropped the TnetServer.zip file on the server, unzipped it, and ran it. Make sure you run it as administrator (right-click the .exe file, run as administrator). Then make sure the server firewall does not block it (and it will out of the box). Then I created a basic client in Unity, to connect to the server. I believe it was about 2 lines of code. Bammm...It connected. Watch the cmd window on the server, and you will see the connect/disconnect messages

I know that there is mention here about using Amazon as a server. Now I don't work for them and I am not endorsing them, but you can sign up for free. They will give you 750 hours per month of server time (750/24 hours = 31 days), 750 free hours of DB time, and some other goodies. I believe this is the best solution when working on that next million-user game. Use it for free during dev and beta, and when your user base gets large and you are willing to pay for it, just spin up more instances.

Hope this helps....
Title: Re: TNet: Tasharen Networking Framework
Post by: joboldo on January 11, 2013, 01:07:59 PM
hey,

I have some more questions ;)

1. I want to make a Mario-Kart like game with 4 players. Does this type of game running smooth over TCP? I read that people recommend UDP for fast-action games. Will you add UDP - support to this package?

2. For updating player positions to all players, is it necessary to make some predictions/interpolation ?

3. Will you add some load balancing logic to this package?

Thank you
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 11, 2013, 01:38:59 PM
1. It already has UDP support. Run the examples, top left corner shows you what the current connection supports.

2. Yes. Each game will need custom interpolation logic, ideally based on player input rather than physics (as this gives the best results).

3. That's out of TNet's scope. TNet is a $45 package, not a $5000 enterprise solution. You can do this easily in any case -- first server players connect to can tell them where to connect to next, thus achieving your load balancing. Bam, you just saved $4955.
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 11, 2013, 01:43:03 PM
Aren :
Well... Thank you very very much for your support. I understand that some newbie questions might be frustrating... Now that I have my answer, I'm ready to go.

Devfo :
Thank you as well Devfo ! Glad to get an answer from someone who tested it on Android. Thank you also for these explainations concerning the Amazon setting. As my student project just should be a "proof of concept", I'm not considering a large scaling solution for the moment (around 20 people will use the app... But it has to work properly anyway !), but it was very helpful, I write this down for any future projects =) !

Cheers everyone !
Title: Re: TNet: Tasharen Networking Framework
Post by: devfo on January 11, 2013, 02:27:24 PM
Forgot to mention, but you may already know:
For Android, you need the unity Pro license. Otherwise you don't have the socket class
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 11, 2013, 02:35:55 PM
Fortunately the Pro licence is provided by the University I'm studying in !
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 16, 2013, 04:55:12 AM
Hi everyone !

I come back to this thread because there are still some points I need to clarify (sorry...!).
I've bought and made some tests with Tnet. I also spun up a Amazon EC2 Instance (Windows server 2012 based too...!), and it's working just fine with the stand-alone server provided by Arren running on it.

However, I'm missing something.
First, I've read the CS files on the TNetServer folder. I understand that the ServerMain one is the code built for the stand-alone server provided by Arren. I guess the ClientMain is something I can use for testing, but how ? How can I build it ? (Yes... I'm that a newbie...).

Secondly, I tried to connect to my Instance with the Example Unity Build provided by Arren, but I couldn't ( by entering the ip address of the instance in which the stand alone server is running). Well I guess it's normal and that I will get obvious answers by posting this post.
But, the thing is that I don't know where to start then now that I set up this stand alone server for global networking.
Could someone post an example code for a unity build simple scene that connect to that client ? Explaining which datas should I enter ?

Once I'll get this working and that I understand it, I would be ready to post a tutorial "zero to hero"-like for setting up a global network (such as the one I'm trying to set up lol).

I'm sure that I'm pretty close to achieve it, but that I just miss some networking basics actually, so maybe I could find my answer by posting this message.

Eventually, Thank you very much Arren for providing such an awesome plugin to the Unity Community, the tests I've done with a local-based network were great and so easy to set up...!

Cheers !
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 16, 2013, 10:33:48 AM
ClientMain is for testing, yeah. I don't advise you to use it. I use it rarely to test things internally. :)

For the Amazon EC2 it can be a bit tricky to set up as you have to open up the port range using the Amazon's web application (followed by rebooting your server). You also have to click "allow" with the "public" checkbox checked when you run the server executable and Windows asks you what to do about the application needing internet permissions. By default only the "local network" checkbox is checked.

I suggest to put stuff on an EC2 cloud as a last step. Run the executable locally and connect to it by specifying "127.0.0.1" as the address.
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 16, 2013, 10:43:22 AM
Hmm okay, I admit EC2 might be a bit tricky for me, I'll do this later...

The thing is that, I have a very simple scene connecting to the address i'm specifying (the computer in which the TNetServer.exe you provided is running).
When I play the scene on Unity (which is running on the same computer), MAGIC : the TNetServer.exe says that I'm connected (Huray ! ).

But, when I build this scene on my android and that I play it, it doesn't work...!
I don't really understand what I'm missing. I'll try to play this scene at home to connect to the computer hosting the TNetServer.exe ...(Maybe it comes from my Android ?)

Cheers.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 16, 2013, 10:49:55 AM
Do you specify your computer's address on the android device? 127.0.0.1 means local device. You need the full address, such as 192.168.1.10

The example that comes with TNet uses the network broadcasting feature to automatically find the server. You can use the same thing to avoid having to type in an IP manually.
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 16, 2013, 10:51:33 AM
Aren : Yes, I specify the IP Address in which the TNetServer.exe is running.

I've tried with the Example Unity Client you provide too, works half on a computer (connect and disconnect immediately), and I tried the apk Example you provide on my android ... doesn't work.

one thing : I don't understand the network broadcasting feature actually, how can the client find a server running on a computer if it's not specified before building it ?

I don't wanna bother you with annoying questions ... Sorry ...
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 16, 2013, 11:11:31 AM
Examples on the website are not compatible with TNetServer.exe that's in the package. The examples are older version, and use an older protocol. You need to build your own examples.

Broadcast feature works by notifying everyone on the same network, so no IP is necessary.
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 16, 2013, 11:24:04 AM
As I've said earlier, I've also built a simple scene connecting to the TNetServer.exe. It works when I play the scene on the same computer as this .exe is running, it is responding.
However, when I play the scene from an Android, it doesn't work...

Let me specify what i'm doing :
TNetServer.exe is running on my computer.

My scene has gameobject with a TNManager script, land my LogMenu script :
"using UnityEngine;
using System.Collections;

public class LogMenu : MonoBehaviour {

public string mTestAddress = "IP Address of computer";
   
   void OnGUI(){
               if(GUI.Button(new Rect(40, 120, 120, 40), "Join")){
         TNManager.Connect(mTestAddress);
               }"
Of course, IP Address of computer IS the IP Address of the computer running the TNetServer.exe (just don't communicate it here ^^' )
And that's it! I build this on my Android device, and when I click the Join button, nothing happens (whereas the TNetServer.exe is responding when I play the scene in the Unity Editor).
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 16, 2013, 06:54:58 PM
Make sure the android device is connected wirelessly to the same network -- that's pretty much all I can suggest. There is no difference between android and other platforms, they all operate the same. To get the examples in the video to work, all I did was just build the default example that comes with TNet with Unity, and it worked as-is. If the TNet's examples work for you, but your own app does not, I'd suggest looking at what's different -- such as trying to print the android device's IP address.
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 18, 2013, 04:21:33 AM
Hi Aren.

Sorry, maybe I wasn't clear enough in my earlier posts.
The fact is that I don't want it to be on the same network. I would like to make it work globally and not locally.

I thought this was possible by reading this thread, and Devfo also said that it worked because it's what he's doing.

So I apologize if I wasn't clear enough at first. Could you give me some further explanations about setting up a global network with TNet ?

Thank you very much, and cheers !
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 18, 2013, 04:26:44 AM
If the android device is able to browse the internet, then it will be able to connect to a remote TNet server.

You said yourself your server .exe is running on a local computer. That's not global. That's local. By default Windows will actively block all attempts to connect to your computer, unless you allow it to get through your firewall (or unless you are attempting to do it from the same exact computer -- which is why the Editor works). Try connecting to your server from a remote computer -- one that's not running the TNetServer.exe.
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 18, 2013, 04:41:53 AM
Thank you very much for replying so quickly Aren !

I've allowed the TNetServer.exe to get it through the Windows firewall.
I also tried to connect to the TNetServer.exe from a remote computer, it didn't work.
Or I'm doing something wrong, nor my university is blocking any access to the computers remotely...

Tell me if i'm not correct : the only thing I should do is to run the TNetServer.exe on a computer. Then try connecting by using the Tnet Example Unity build you provide, by entering the IP Address of the computer running the TNetServer.exe and click connect , right ?

If it comes from my University network, I'll try to do it from home with my android...

Thanks again for your time Aren !
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 18, 2013, 04:47:32 AM
University network... that sounds like a red flag right there.

Yes, that's all you have to do (in addition to checking the "allow public network access" dialog when running TNetServer.exe for the first time).
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 18, 2013, 04:58:48 AM
Okay Aren, thanks again.

Then i'll try it at home and inform the tech guys from my University.
However, I've never had the "allow public network access" dialog when running the TNetServer.exe, even the first time ! O_O
But nevermind... I'll keep you updated once I'd try it at home.
Enjoy your day/night ? ^^
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 18, 2013, 05:02:05 AM
(http://www.tasharen.com/tnet/dialog.jpg)
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 18, 2013, 05:04:20 AM
Haha ! Thank you Aren !
But... never had this pop up !
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 18, 2013, 05:05:13 AM
Then your Windows always blocks it, and doesn't even ask you.
Title: Re: TNet: Tasharen Networking Framework
Post by: Yarashiel on January 18, 2013, 05:07:13 AM
Nice to know x)
Okay okay, we're getting close to the solution !
Title: Re: TNet: Tasharen Networking Framework
Post by: ahgElliot on January 20, 2013, 01:12:49 AM
Hi there,
I've been working on a game and I would like to use TNet for it.  I've already purchased the package and have some of my basics working.  I am running into one issue where I need to get the item that was just instantiated by the network.  It seems this functionality is missing.  I would like to be able to get a NetworkObjectID or a GO from the TNet.Create or TNet.Instantiate methods.

Why would I want to do this?

I've made a game database system and pick up system loosely based off your example from NGUI and the orc inventory/item database.  I have a GamePickup script that I put on a GO and turned into a prefab that has a "SetItem" method on it that I turned into an RFC in preparation for this functionality.  I've added that prefab to the TNManager and it creates the item correctly, but I can't call the RFC because (unless I'm missing something) there is no way for me to get the object out of the TNManager when you instantiate or create an item. 

Is there a way to do this?  Is this something you think I could easily add in?  Would it make sense to have hundreds or potentially thousands of unique object ids in the TNManager considering each item in the game that gets dropped will generate a unique ID?

What approach would you take to accomplish this?  I'm not sure if my current implementation is going to work or if TNet is the best solution for this.

Thanks,
Elliot
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 20, 2013, 05:29:52 AM
Have a script attached to your instantiated object. Inside its Awake() function, check TNManager.isThisMyObject -- this will only be 'true' if you are the one who instantiated this object. All other clients will see this as 'false'.
Title: Re: TNet: Tasharen Networking Framework
Post by: enzi on January 20, 2013, 08:11:50 AM
Hi there!

I have a question regarding the standalone server. How is it possible to get events in the standalone server?
The position values are sent with UDP from the client but for security purposes I also want the server to know about it so I can prevent teleport hacks and stuff.

Overall the standalone Server API seems a little thin. For example the CreateChannel method is private, not sure why. Giving the client the ability to create channels seems a little risky unless you really want them to be able to.

So, before I start to rewrite stuff it would be great if you can give me some tips to handle that. It's my first networking project so I'm not that fit when it comes to designing this.

Thanks and greetings from austria!
Thomas
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 20, 2013, 10:02:35 AM
I would suggest doing teleport hack checks on the client if/when possible. You can still "review" packets on the server, but since TNet's main design revolves around sending RFCs, your best bet will be to create custom packet types for stuff you want checkable by the server, and then add the check logic when the server receives this type of a packet.

In the long run, the more you have on the client, the easier your life will be and the more players your server will be able to support.
Title: Re: TNet: Tasharen Networking Framework
Post by: enzi on January 20, 2013, 06:25:54 PM
Thanks I'll keep that in mind.

And how can I setup the events in the server?

Is there something where I can read the received TCP/UPD packets via API?
Or should I rewrite the TNGamerServer.cs?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 20, 2013, 06:46:20 PM
Rewrite? Nah. But you will want to modify TNet.GameServer.ProcessChannelPacket, adding your packets in there.
Title: Re: TNet: Tasharen Networking Framework
Post by: enzi on January 21, 2013, 08:39:23 AM
Hehe, yeah, modifying is what I meant. No need to rewrite solid code. ;)

Can you tell me a little about the overall architecture? What I'm really interested in, is what's happening in SendQuickly and Send with UDP. From my understanding now a UDP packet should be recieved from every client/server that is listening on the UDP port. Is this correct? Or does the packet get sent to the server and the server sends it to the client(s)?

Apart from that, I've everything up and running thanks to your framework. Now it's more of getting lag compensation and all this boring stuff.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 21, 2013, 08:56:12 AM
SendQuickly will send via UDP if a UDP communication has been proven to be functional. Otherwise it will go through TCP. It's all completely seamless to you as a developer. It's all processed exactly the same as well. The server will send a UDP-arrived packet via UDP as well, whenever possible.
Title: Re: TNet: Tasharen Networking Framework
Post by: ahgElliot on January 21, 2013, 10:32:42 AM
Hey there,
Some more woes with getting my game up and running.  In my old networking code I used to just give each their own network view and had the view synchronize my players and it worked as expected.  In TNet I'm finding that if I take my Player class and have it pull from TNBehavior that my players do get connected to the same game/channel (I added in some things to the server to report on this) and they are sharing other networked objects (I have pickups that disappear when one player or the other picks them up). Also, my Player Prefab is created by the TNManager when the player connects to the level and they can control themselves fine.

However, the model for each player is not being created in the networked game.  I only see one player on each instance of the game.  My player prefab is laid out like this:
______________________________
Player (GO)
 |-Stats (component on Player GO)
 |-Equipment/Storage (component on Player GO)
 |->HUD (GO)
 |->Model (GO)
 |->Vision (GO)
______________________________

It's clear that there are 2 players, but the model component doesn't seem to be shared on all clients.

What do you recommend I do here?

Thanks,
Elliot

PS: Are this (http://"http://www.tasharen.com/?page_id=4523") and this (http://"http://www.tasharen.com/?page_id=4537") the only available documentation for TNet?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 21, 2013, 10:37:17 AM
You need to instantiate a new player for each client that joins the channel. Easiest way to do this is to have a script with a Start() function in it that will do a TNManager.Create call with the prefab of your player.

In a script attached to the player prefab you're instantiating, you can check in its Awake() function whether you're the one who created this object by checking TNManager.isThisMyObject.
Title: Re: TNet: Tasharen Networking Framework
Post by: ahgElliot on January 21, 2013, 10:54:23 AM
Ok. I think I know what you mean.  I'll try again tonight and see if I have more success.  Thanks for the quick replies.
Title: Re: TNet: Tasharen Networking Framework
Post by: Zaibach333 on January 21, 2013, 04:31:03 PM
Hi,

I am generating a grid for my turn based strategy game, the host has the grid data and I want to change Instantiate to TNManager.Create but Create doesn't return anything, how would I go about this without a headache?

here's the strip using Instantiate:

  1. //generate grid
  2.   tileActorGrid = new List<List<TileActor>>();
  3.          
  4.   for (int i = 0; i < SessionManager.instance.map.size; i++) {
  5.       List<TileActor> row = new List<TileActor>();
  6.       for (int j = 0; j < SessionManager.instance.map.size; j++) {
  7.           int id = SessionManager.instance.map.grid[i][j].id;
  8.                
  9.           Vector3 pos = new Vector3(-SessionManager.instance.map.size/2 + j ,0,SessionManager.instance.map.size/2 - i);
  10.           Quaternion rot = Quaternion.Euler(new Vector3(0,0,0));
  11.          
  12.           TileActor tile = (TileActor)((GameObject)Instantiate(SessionManager.instance.getPrefabByTileId(id), pos, rot)).GetComponent<TileActor>();
  13.           row.Add(tile);
  14.       }
  15.       tileActorGrid.Add(row);
  16.   }
  17.  
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 21, 2013, 04:53:54 PM
I already answered this question above:
Quote
In a script attached to the prefab you're instantiating, you can check in its Awake() function whether you're the one who created this object by checking TNManager.isThisMyObject.
Title: Re: TNet: Tasharen Networking Framework
Post by: Zaibach333 on January 21, 2013, 08:49:24 PM
Oh, sorry.

I thought I could get a reference to the object immediately after the call ...

what I ended up doing was Instantiate on the host then replace the host grid as they are created via TNManager with Awake() like you said.

Still happens almost immediately.

Thanks.

Title: Re: TNet: Tasharen Networking Framework
Post by: Smooth P on January 22, 2013, 10:15:21 AM
Ah, good point about AutoSync. I've fixed it like so:
  1.                                 // Only start the coroutine if we wanted to run periodic updates
  2.                                 if (updatesPerSecond > 0 && TNManager.isConnected)
  3.                                 {
  4.                                         // If we're already in a channel, we can now sync this object
  5.                                         if (TNManager.isInChannel) mCanSync = true;
  6.                                         StartCoroutine(PeriodicSync());
  7.                                 }
  8.                                 else enabled = false;
I'll change it to +=, but any reason you don't want to just rely on automatic OnNetwork* series of functions?

I'm a garage dev who loves NGUI, and just purchased TNet.  I come from a programming background where we rely on type safety and avoid string matches, reflection, and magic bindings like the plague.  So I do all of my event notifications with delegates, which I nearly always bind in Awake().

And I would also like this changed to +=, not for the sake of changes, but because it's the _correct_ thing to do!  :)

Oh, and with TNet I'll be using Enums for all of my RFC identifiers, which is sweet!

(And, yes, typing in Unity has been extremely painful in many ways since the component system doesn't understand interfaces or generics and thus I often have to compromise my design sense and / or create a ton of what should be completely unnecessary boilerplate code, but that's a topic for another day.  And why, oh, why didn't they update the Mono version in 4.0 and am I still relying on my own algebraic classes and dealing with an invariant IEnumerable<T>?  UGGG!).
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 22, 2013, 03:55:14 PM
Hi Aren,

Theoretically .. wouldn't it be possible for me to create a serverside Unity client and connect it to TN and use that server side unity client as a way to handle physics?

For example

[PC Client] >> [TNet] >> [Server Client]
then
[Server Client] >> [TNet] >> [PC Client]

Basically TNet acts as a middle layer between the Server Client and the PC Client. The Server Client will always be the host. Can I get away with this in TNet? I know it's possible with Photon Server.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 22, 2013, 08:56:01 PM
Yup!

And since the first client to join the channel is always the "host" (authoritative player), your unity's client will essentially do physics on the server.
Title: Re: TNet: Tasharen Networking Framework
Post by: zipper on January 22, 2013, 10:38:55 PM
Hi ArenMook,
Happy NGUI user here :)

I have a Flash socket server (TCP) i need to connect to on a local network. I know this much about networking ><. Can i use your networking framework to talk to it? Basically, i just need to read and write strings to the host - port, non-blocking if possible.

Best,
zipper

Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 22, 2013, 11:03:39 PM
TNet clients are designed to connect only to a TNet server, and TNet doesn't support Flash because Unity's Flash export doesn't support Reflection. I don't think TNet is going to be helpful in your case.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 23, 2013, 08:21:07 AM
I'm experiencing a bug with the latest version... it's a bit strange.

When I open two windows on my machine and start clicking around... changes only happen on one window until I bring another window into focus. Only then will the changes sync for the other window. And the server keeps disconnecting me automatically. (I'm using the demo scenes with the latest version).

I know it's not my system because I ran the version 1 server and downloaded the client from this web site.. and all windows synced instantly. Even the ones in the background. Also no forced disconnects.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 23, 2013, 08:35:58 AM
You need to check the "Application runs in background" checkbox.

Unity automatically puts the app to sleep when it loses focus.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 23, 2013, 10:41:58 AM
You need to check the "Application runs in background" checkbox.

Unity automatically puts the app to sleep when it loses focus.

*face palm* .... thanks Aren, that solved it.  :-X
Title: Re: TNet: Tasharen Networking Framework
Post by: byerdelen on January 23, 2013, 01:46:08 PM
Hi ArenMook,
I am experienced programmer but I have very little experience with networking. I watched video, checked documentation, checked forums and it seems this package can do the hardest part well. Before buying I would just have 2-3 small questions, I do not want to waste your time so I would appreciate if you would answer with yes or no even
-I am planning to develop a small social game and the network necessities are very close to a poker game although the game is very different, I will need to create rooms, an authoritative server, 10-20 thousand people max playing simultaneously (as four people groups). The game will randomly put people to four people's group and get and respond messages in every 3-5 seconds. Just to be sure before giving lots of effort, do you think this framework is capable to do those fully and efficient?
-Will there be any huge effort to setup the server running except Unity and your framework?
-(You can ignore this question if you find it irrevelant) What kind of bandwidth do you think for that kind of game?

Thanks a lot and congratulations on all your wonderful frameworks
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 23, 2013, 01:51:15 PM
1. Yes, this is easy, but 10-20k people on the same server? You may need multiple servers due to how sockets are handled by the operating system (so it also depends on the operating system).

2. You can set up a server by running the TNetServer executable on the computer of your choice. Now the question is how much modification will you need to do to the server itself? Anti-hacking measures and such will imply modifying the server code.

3. I really can't estimate on the bandwidth as I don't know what you will be sending. My guess -- very little, since you're only sending data every few seconds.
Title: Re: TNet: Tasharen Networking Framework
Post by: byerdelen on January 23, 2013, 01:58:13 PM
Ok, those clarified my mind if I will need some other network solutions or not. It seems it is capable to do my needs. Thanks a lot
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 23, 2013, 02:01:36 PM
So, everything is working now with updated TNet assets.. connection works as expected however when I view "Example 3"... The blocks don't move in realtime on the different clients. The blocks on other clients only update when I release the mouse.

If I recall, in the previous version of TNet, whenever I dragged a block, it would move the blocks on other clients in realtime.

PS: I'm running the server from a Rackspace hosted box. I opened up the TCP ports for 5127-5130. Is there something else I need to do for that example to work?

PSS: It works perfectly on local host servers.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 23, 2013, 03:25:05 PM
Those position updates are sent via UDP, not TCP. Sounds like your UDP packets are getting lost.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 23, 2013, 06:46:41 PM
Those position updates are sent via UDP, not TCP. Sounds like your UDP packets are getting lost.

Yup! so when I got home I tested the same code and the UDP packets were sent with no problem, which means some networks may not be able to do UDP. Is there a way we can get a "isUDPSupported" flag so we can fall back to TCP if needed?

Pretty PLeeeeeaaseee!!
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 23, 2013, 06:47:55 PM
It should do that by default, actually. When you connect to the server in the example, you should see what type of a connection you have in the top left corner.
Title: Re: TNet: Tasharen Networking Framework
Post by: xfinitystudios on January 23, 2013, 06:55:21 PM
Yea, it showed (TCP + UDP) ... but no UDP stuff was working on that network (it was my job's network). If I knew how to turn off UDP on my Mac I'd try to replicate it here at home.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 23, 2013, 06:58:38 PM
Curious. TNet doesn't enable UDP unless it has been confirmed to work (a packet arrived successfully). You might have to debug that one.
Title: Re: TNet: Tasharen Networking Framework
Post by: enzi on January 23, 2013, 07:12:52 PM
Hi!

I need to synchronize the server/client time but it's getting inaccurate because I don't know how long a packet needed to be received. In unity networking there's NetworkMessageInfo.timestamp" with which I can calculate the travel time via "Network.Time - NetworkMessageInfo.timestamp".

Is their a equivalent in your framework or do you know a way to do this in C#? Google didn't help me :(

Thanks!
Title: Re: TNet: Tasharen Networking Framework
Post by: danreid70 on January 23, 2013, 07:17:14 PM
Hi Aren - I love your NGUI (purchased it a few months back, and only now getting to it - kind of a spare time project I'm working on for fun). I really want to (and will) purchase TNet - after reading the forums here and on Unity Forums, TNet sounds PERFECT for my game.

What are the chances you could put a sample in the TNet package, with a character controller - and a very simple connect/choose-lobby/choose-level/launch-level-with-synced-character-controller menu, using NGUI? That's the part I keep getting stuck on. Just something very simplistic.

The reason I ask, is I keep thinking I have the right structure with NGUI, but then I look back at your examples and I keep redoing basic parts as I see how clean you did them in your samples. Your setups are very clean, and I'd like to try and follow that same example with TNet using the NGUI menu. Or do you already have a sample like this in the package?

I'm currently using a very spaghetti-coded Unity networking solution, that I'm wanting to scrap and just start all over with - which is why I started looking at TNet...

Thanks already for NGUI, and keep up the great work with TNet! I'll be purchasing VERY soon!
--Dan
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 23, 2013, 07:27:16 PM
@enzi: Network.time is actually really unreliable in Unity. I know from personal experience -_-. I've seen over a second difference playing locally (!) in some cases. TNManager has a "ping" parameter that you can use, but there is no concept of "network time" in TNet. What do you need it for anyhow?

@danreid70: There is no character controller example with TNet. It's really simple to do though. In OnNetworkJoinChannel, TNManager.Create your player, and in a script attached to the player check -- TNManager.isThisMyObject? If so, control it. Otherwise let someone else control it.

Title: Re: TNet: Tasharen Networking Framework
Post by: enzi on January 23, 2013, 08:15:18 PM
I got it working. Thanks to the setup it's a breeze to put in new responses and requests.

But unfortunately I was on the wrong track. I thought my position interpolation got out of sync due to wrong timestamps from the server and the client. I'm using DateTime.Now.ticks. But that was never the issue to begin with.

For some reason the character controller on the server moves at a slightly higher speed. It's probably a totally stupid bug but I've checked nearly everything (is the fixed timestep correct, calculating the actual speed of the server/client) and from the data I gathered everything SHOULD be fine but it's not. I understand latency but not why the damn server character always outruns my client character. Makes no sense.

Oh well, I'll just sleep over it. That always helps. ^^
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 24, 2013, 09:28:54 AM
Check the framerate. More often than not such things are caused by forgetting to take Time.deltaTime into account in your Update functions.
Title: Re: TNet: Tasharen Networking Framework
Post by: enzi on January 24, 2013, 10:29:30 AM
I do all my movement calculations in FixedUpdate with a timestep of 20ms. It's crude as I don't have any complex accelerations and stuff in it. It's running with the same speed locally but not on the server.

I've to dig deeper. :)
Title: Re: TNet: Tasharen Networking Framework
Post by: zyeurgh on January 24, 2013, 07:18:21 PM
Hi guys,

TNet has proven quite cool to use so far, good job on that :)

Now, I was trying to implement an entity interpolation solution for my game based on this:
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking (https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking)

It looks like it's quite dependent on clients/server having the same time, to allow to draw other players "in the past".
So I guess that rejoins the question that enzi had about the equivalent of Unity's NetworkMessageInfo.timestamp.
Since there is no notion of network time in tnet, I'll probably have a look at syncing time with the different clients too, using the ping maybe.
Or would you recommend another technique for players interpolation in a fps kind of game?

Cheers,
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 24, 2013, 09:05:12 PM
When a new player joins the channel, host can send that player Time.realTimeSinceStartup. Add ping to that, and you will have a network time (as approximate as Unity's approach gets anyhow).
Title: Re: TNet: Tasharen Networking Framework
Post by: zyeurgh on January 25, 2013, 10:44:21 AM
Thanks, I'll give that a go.
Title: Re: TNet: Tasharen Networking Framework
Post by: enzi on January 25, 2013, 12:39:20 PM
Zyeurgh, if you are working with DateTime.Now, keep in mind that it can be different on each client. You also have to sync this. I had to do this. But for overall timing I'm using simulation duration now instead of timestamps. The are annoying to work with because they are so inaccurate. So don't use them if you really need exact timings.
Title: Re: TNet: Tasharen Networking Framework
Post by: sunriser on January 25, 2013, 04:22:24 PM
I have a turn-based card game that I want to implement networking on. This package seems to do what I want but I have a few questions.

My game design uses a client game manager object to update the GUI(NGUI, that is ;) )/gameobjects on screen and a "server" object that runs all the game logic with AI, etc. Originally, for Multi-player online, I was going to have a server computer run an instance of each "room" and disable the client game manager and screen GUI/gameobjects and just run the "server" game object using UDP messaging to/from the clients in the same room.  That may start to tax the resources of the server too quickly when I ramp up usage and have too many instances of a gameserver running on the server computer.

I like the idea of using a host player with token-passing capability if host connection is dropped, but:
 

Basically I want to make sure all "server" object states get accurately synced to all players who may become alternate hosts.

Which method would be best to use?

Thank you and I'm very excited about using this framework!
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 25, 2013, 10:18:00 PM
1. All clients should always be sync'd. When you do a Send to all, everyone gets the packet. The TNManager.isHosting client should be the only one to send out AI updates, however. You need to think less dungeon master, more group leader.

2. AutoSync can be used so automatically synchronize a public variable or property across all clients. Just attach the script to an object, and choose it from the drop-down list. If you need a tutorial for this, then something is really wrong. :)

3. Only the host should be sending out updates, as I mentioned in #1. But yes, all clients should be receiving them.

Based on your questions, I highly recommend you familiarize yourself with the examples in TNet before going further. You're approaching it from a traditional "server knows everything" perspective, when in TNet a server is simply there to forward packets between clients, and the authoritative player is the one that does all logic. It's a much cleaner design, and once you wrap your head around to it, you will be able to reduce your code paths significantly.
Title: Re: TNet: Tasharen Networking Framework
Post by: Zaibach333 on January 26, 2013, 08:01:02 AM
I'm running into a couple things with my game's server and TNet.

I used mostly the menu example code for starting the server but I run into this error:
Quote
NullReferenceException: Object reference not set to an instance of an object
TNet.UdpProtocol.Broadcast (TNet.Buffer buffer, Int32 port) (at Assets/TNet/Common/TNUdpProtocol.cs:199)
TNet.GameClient.EndSend (Int32 port) (at Assets/TNet/Client/TNGameClient.cs:348)
TNManager.EndSend (Int32 port) (at Assets/TNet/Client/TNManager.cs:484)
TNDiscoveryClient.RequestUpdate () (at Assets/TNet/Client/TNDiscoveryClient.cs:105)
TNDiscoveryClient+<PeriodicRequest>c__Iterator2.MoveNext () (at Assets/TNet/Client/TNDiscoveryClient.cs:89)

So I commented out all the UDP and TNDiscoveryClient I had in my script and it ran fine for a while but now I'm getting this error:
Quote
Exception has been thrown by the target of an invocation.
GameManager.RequestFinishDeployment ()
UnityEngine.Debug:LogError

(Object)
TNObject:Execute(Byte, Object[]) (at

Assets/TNet/Client/TNObject.cs:250)
TNObject:FindAndExecute(UInt32,

Byte, Object[]) (at Assets/TNet/Client/TNObject.cs:320)
TNObject:SendRFC(UInt32, Byte, String, Target, Boolean, Object[])

(at Assets/TNet/Client/TNObject.cs:499)
TNObject:Send(Byte, Target,

Object[]) (at Assets/TNet/Client/TNObject.cs:402)
GameManager:DrawDeploymentButton() (at

Assets/Paul_assets/scripts/Game/GameManager.cs:245)
GameManager:OnGUI() (at

Assets/Paul_assets/scripts/Game/GameManager.cs:173)

What's weird about that last one is it only seems to happen when I stop then start the server again. *I apologize in advance if this is another dumb question.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 26, 2013, 07:54:33 PM
Your error log points to a problem in GameManager.RequestFinishDeployment function, which is game code, not TNet.
Title: Re: TNet: Tasharen Networking Framework
Post by: Zaibach333 on January 27, 2013, 12:19:59 AM
this is GameManager.RequestFinishDeployment :

  1. [RFC(12)] void RequestFinishDeployment() {
  2.         if (TNManager.isHosting) {     
  3.                 tno.Send(14, Target.AllSaved);
  4.         }
  5. }

and 14 exists too:
  1. [RFC(14)] void SetToTurnSequence() {
  2.         deployment = false;
  3.         movement = true;
  4. }

is there a limit to the amount of RFC calls?
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 27, 2013, 12:37:52 AM
You don't have to specify an ID for RFCs. IDs are only useful if you are trying to optimize bandwidth usage. You can have up to 255 unique IDs on the same TNObject.

P.S. Make sure your RFC ID (14) is not used on another script on the same TNObject, or you will have weird issues. Also... is there a reason why you do what you do? RequestFinishDeployment only does something on the host... so why not just set the 12's call to be Target.Host, and not do this?
Title: Re: TNet: Tasharen Networking Framework
Post by: Zaibach333 on January 27, 2013, 02:39:24 AM
Figured it out, I had to test without having any clients and setting all my RFC calls to straight up methods but down the line it ran into some TNManager.players issues, I just check if the index I have saved is larger than the list.

RequestFinishDeployment() was the first version of the method, now it has a counter on call which triggers 14 only when all the players have requested to finish deployment.

Thanks a bunch, it was bringing me inside your TNObject code which I don't want to change.
Title: Re: TNet: Tasharen Networking Framework
Post by: enzi on January 27, 2013, 08:16:11 AM
Quick question. In TNGameServer.cs every EndSend has mBuffer.EndTcpPacket even when reliable is false. Is this intended? If yes, why is that?
Title: Re: TNet: Tasharen Networking Framework
Post by: byerdelen on January 27, 2013, 10:54:21 AM
Hi ArenMook,
I am able to communicate my devices from a non-local server. I will have two questions that I couldn't find the answers anywhere.
-I want to get some variables from the host when a device is joined. There is a send message but is there a request message from device to the host so I can get some live variables from the game managing host when the device is opened?
-Also in send message, there is Target.All, Target.Other messages. I want to reach only host or maybe a specific device-id. Is there a chance that I can specify Target.Host and Target.(deviceid)?
-I am building all my network according to a host-manager which is working inside server. To understand the server has an amount of users registered and direct user to another server, is there a way that I request information from the server which servers are more than this number? I can join servers and learn it from the host but it will connect device to servers and ask and disconnect and try it on the next server but it is not efficient so there is a way to learn it from main client in server maybe?

Thanks and sorry for my network-amateur questions if the answers are obvious.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 27, 2013, 01:41:13 PM
@enzi: Yeah it's intended. It's just for consistency. UDP packets always arrive whole, while TCP packets are fragmented and can arrive in parts, so I write the packet's size before the actual packet for TCP. This way I know how much data needs to arrive before the packet is processed. I simply kept the same logic for UDP so there is no distinction between the two as far as data processing and forwarding goes. This also makes it possible to forward a UDP packet via TCP seamlessly.

@byerdelen: Your best bet is to save the variables on the server (and echo them to everyone) by keeping them synchronized via tno.Send(ID, Target.OthersSaved, your values). This way everyone is up to date, and new players get these automatically.

There is a Target.Host already. For other players, specify a Player instead of a Target. But as I said, I recommend you just using Target.OthersSaved to keep everyone on the same page.

Yes you can design your lobby to do load balancing this way, sure. One of the features in TNet is the Discovery Client. It contains a list of known servers (TNDiscoveryClient.knownServers). You could extend the TNServerList to have an additional parameter in its data: number of players.

In fact... I've just added it. You can wait for the next version or ping me on Skype (arenmook) with your order # and I'll give you the modified version.
Title: Re: TNet: Tasharen Networking Framework
Post by: byerdelen on January 27, 2013, 02:02:51 PM
Awesome, answer to my all questions, thanks.
I guess it will take some weeks for me to get that point to check the server player numbers, I can wait for the next update, again thanks alot for your concern.

I would like to add something to have more knowledge.
I guess you are using your array list TNet.List. This creates ambiguous reference with Generic ArrayList. Because of that, I cannot use Generic List in where I am using import Tnet; . Also I cannot use useful the generic list functions such as Contains, Sort etc.   Is there any way to solve this issue?
I need it because when I want to pass your lists as Tnet lists to other users using Send("function",Target.All,playerlists), it gives me this type of crash message and crashes my devices :
Unable to save type TNet.List`1[System.String]
UnityEngine.Debug:LogError(Object)
TNet.Tools:Write(BinaryWriter, Object[]) (at Assets/TNet/Client/TNTools.cs:250)
TNObject:SendRFC(UInt32, Byte, String, Target, Boolean, Object[]) (at Assets/TNet/Client/TNObject.cs:486)
TNObject:Send(String, Target, Object[]) (at Assets/TNet/Client/TNObject.cs:407)
ExampleChat:Start() (at Assets/TNet/Examples/Scripts/ExampleChat.cs:47)


So I cannot send your arrays, am I doing something wrong?
Thanks
Title: Re: TNet: Tasharen Networking Framework
Post by: zyeurgh on January 27, 2013, 05:08:48 PM
Hi,
So I have my interpolation/extrapolation in place. It seems ok when I look at another player moving around but when the other player and the local player are moving in the same direction (jump at the same time for example), I get really annoying jittering on the other player.
Would you have an idea on what could cause such issues? Why just when we move in the same direction?
Cheers,
Title: Re: TNet: Tasharen Networking Framework
Post by: matis on January 28, 2013, 08:06:36 AM
Hi,
Iam tryed instantiate object as a child but I have problem with this when using TNManager.Create command instead Instantiate.
My code with Instantiate:
  1. (Instantiate (terrains [Random.Range (0, terrains.Length)], ter_position[i].transform.position, ter_position[i].transform.rotation) as GameObject).transform.parent = ter_position[i].transform.parent;

This is work great I know that TNManager.Create dont work like Instantiate so I must add Instantiated object as a child by another way but I cant figure out any easy way.:( If someone can give me advice as for not very skilled coder or even better code for that I will be grateful.
Thanks to all.
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 28, 2013, 02:23:46 PM
@byerdelen: TNet.List is a dynamic templated type. You can't pass it as an argument to an RFC call. If you want it to be passed, use its ToArray() function first to turn it into a fixed-size array. Also, TNet.List has support for both Sort and Contain functions. It's designed to flat out replace the generic List type.

@zyeurgh: My guess is that you are not smoothing the values, or you didn't separate the renderer from the rigidbody. Look at how I set up the boxes in the Create example.

@matis: TNManager.Create is an asynchronous call and it has no return type. If you want to do anything with it, do it in an Awake() call in a script attached to the object you're instantiating. TNManager.isThisMyObject tells you if you're the one who created it.
Title: Re: TNet: Tasharen Networking Framework
Post by: KJIB on January 29, 2013, 06:27:47 AM
I notice that, after starting the server, if you then select chat, (no clients, just the server) and then change your name to (say) "Fred" in the chat example, it informs you that "Fred is now known as Fred" as it has already overwritten the old name before displaying it...  :o
Title: Re: TNet: Tasharen Networking Framework
Post by: zyeurgh on January 29, 2013, 09:45:48 AM
Thanks for your reply ArenMook,
I think my problem was that the local players were updating on FixedUpdate (using CharacterController) and the remote players were interpolated in Update, which was causing jittering when moving in the same direction. It's all smooth now :)
Title: Re: TNet: Tasharen Networking Framework
Post by: ArenMook on January 30, 2013, 07:01:18 PM
Please start individual threads now instead of replying here -- it will be easier for others to find the information they need later.