Author Topic: TNet: Tasharen Networking Framework  (Read 66141 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 261
  • -Receive: 1125
  • Posts: 21,784
  • Toronto, Canada
    • View Profile
TNet: Tasharen Networking Framework
« 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?
  • It's Open: written in C#, comes as full source code for you to modify as you see fit.
  • It's Readable: The code was written for others: it's clean and thoroughly commented.
  • It's Flexible: Server can be stand-alone, or started on another thread right within Unity.
  • It's Adaptable: "Host" disconnects? Choose another. The game doesn't end. Everyone disconnects? Save the state (if you want).
  • It's Persistent: Not only can remote function calls be saved for future players, but you can save the entire server's current state and then restart it. When you start it back up, it will be as if you've never shut it down (Auto-save anyone?)
  • It's Powerful: Written to take advantage of high efficiency sockets (IO completion ports).
  • It's Spacious: Each channel on the server is a separate area with its own rules (and save file), letting you host as many simultaneous games as your bandwidth can handle.
  • It's Private: Playing by yourself? Put a password on the channel, or just flat out lock it. Others will still be able to PM you, of course.
  • It's Consistent: You don't need to put "if" statements everywhere. Same code that works for multi-player will work in single-player. The callback order is always the same. For example, players always get "left channel" notification before a "disconnect".
  • It's Efficient: You can optimize your frequent remote function calls by specifying a byte ID instead of a function name. Less data will be sent.
  • It's Straightforward: Remote function call syntax and number of parameters are up to you. Arrays? Sure. Binary data? No problem. A hundred parameters? Uh. Well, sure, if you want.
  • It's Elegant: You can even broadcast messages to players on the same LAN or wireless network without requiring them to connect to the server. Perfect for announcing local servers, for example.
  • It's Useful: You can save files directly to the server, and load them later, letting players save their avatar thumbnail, inventory, or even an entire game map for others to load.
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:
« Last Edit: December 10, 2012, 05:31:03 PM by ArenMook »

aidji

  • Guest
Re: TNet: Tasharen Networking Framework
« Reply #1 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 261
  • -Receive: 1125
  • Posts: 21,784
  • Toronto, Canada
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #2 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.

Cripple

  • TNP Alpha
  • Full Member
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #3 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 ?

Graphicstream Dev.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 261
  • -Receive: 1125
  • Posts: 21,784
  • Toronto, Canada
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #4 on: December 11, 2012, 09:57:15 AM »
Probably $45 initially. Fairly cheap.

Cripple

  • TNP Alpha
  • Full Member
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #5 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 ?
Graphicstream Dev.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 261
  • -Receive: 1125
  • Posts: 21,784
  • Toronto, Canada
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #6 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.

SketchWork

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #7 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 :)
« Last Edit: December 11, 2012, 07:26:26 PM by SketchWork »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 261
  • -Receive: 1125
  • Posts: 21,784
  • Toronto, Canada
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #8 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.

SketchWork

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #9 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.
« Last Edit: December 12, 2012, 05:30:11 AM by SketchWork »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 261
  • -Receive: 1125
  • Posts: 21,784
  • Toronto, Canada
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #10 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).

SketchWork

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #11 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 261
  • -Receive: 1125
  • Posts: 21,784
  • Toronto, Canada
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #12 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.

SketchWork

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #13 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.

AntiAction

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: TNet: Tasharen Networking Framework
« Reply #14 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.