Master Server Framework

Links:
Asset Store: Unity Asset Store - The Best Assets for Game Making
Wiki: GitHub
Issues, bugs, feature requests: GitHub
Demo: WebGl (running on a 512 RAM, single core, 5$/month VPS).
Video: working on it
Discord: Master Server Framework
Latest version: v2.0.3. Asset store version: v2.0.3

To anyone wondering - I avoid reading unity forums and PM’s, so if you want to contact me - do it through GitHub page. Thank you!:

Is This Asset For you?



Description:
Develop, run and debug your back-end server like a regular Unity game, within editor. No tedious multi-language setups, no third party services with monthly subscriptions, no cap on CCU or traffic, host on win and linux VPS, full source code - even if I die, you move forward. Based on socket connections (think Photon Server, just without caps and monthly payments). If you’re worried about unity’s process overhead, read here.

Master Server Framework is designed to kickstart your back-end development, it contains boilerplate code for user authentication, dynamic / automatically synchronized player profiles, and scalable game servers (rooms) architecture.

At the time of writing, included modules are:

  • Authentication module - manages user registration / logging in
  • Profiles module - build your player profiles without having to worry about database structures, persistence or synchronizing profiles between servers.
  • Game Servers module - allows to register game servers to master server, so that they can be found by players (lobby), or used to create matchmakers. Game servers can access player profiles and update them (give exp on kill, etc.)
  • Spawner Servers module - allows to spawn game servers on users request (user created game rooms). Spawned servers will have full authority - users don’t need to act as hosts, which allows even Browser and mobile users to create game rooms - no need for relay servers or NAT punch-through.
  • Chat module - simple chat module with support for channels and private messaging

Servers and modules communicate to each other through Barebones Networking API (UDP / RUDP / Websockets), which you can use to write any kind of server you want. (It’s an abstraction layer on top of uNET Transport Layer and websocket-sharp, but you can easily write your own implementations if needed ) More info.

7 Likes

Looks good! Can’t wait to see more!!

Looks freakin awesome! :slight_smile:

I’m quite interested in this package!

Looks really great. Curious why Barebones Networking API not UNet?

Networking API might not have been the best name for it, haha. It’s actually a small layer of abstraction on top of low-level networking libraries. Underneath, it’s using UNet low level api (transport layer) for UDP, and websocket-sharp for websockets. This abstraction allows you to have networking technology independent code. For example, if you’ve decided to use raw TCP connections, or switch from unet to, say, lidgren, you could do that without changing a line of your networking code.

I could have used UNet directly, but that would make it impossible to switch technologies if the need arises. Imagine having to refactor every single line of code where you send, receive and handle a message - it would be a nightmare! Which is more, abstraction allows you to have a number of helpful methods that don’t need to change when you switch libraries.

Let me know if I didn’t explain it well enough ; )

EDIT: I’ve updated the description to inform that uNET is used underneath

Hello!

I’m currently looking for a solution to make multiscene unet hlapi (llapi later) dedicated authocrative server for simple mmorpg.
Am I found one?

Can masterserver be coded not to matchmake but to direct and REdirect clients to different gameservers depending on some ingame logic (going to another location or instancing a dungeon)?

Do your asset messes with how actual gamesession should be made? For example do I have to use LLAPI and manually sync marshal data or HLAPI is good enough?

What are possible caveats to use this framework for mmorpg server?

Thanks so much alcyxaz! That clears things up and makes total sense. I’ve got a couple more stupid questions…

  1. I think I saw it or you say somewhere it doesn’t handle the game networking. Obviously I can see in the screenshots, demo, and docs that it does have a game server. So what I’m wondering is what’s involved in going the next step and adding item drops, spells, monsters? Can I just make it so the game server on linux is authoritative? Meaning, it just takes player input and sends back what they should do? (like uMMO?) or do I have to create events for everything and fire those?
  2. Like this, attach a script, and use a different class to GetAxis?
  3. Does it serialize it to/from client/server (eg. JSON)?

To shamsfk:
Yes, you can use the master server to direct to instances and etc. At it’s core, Master Server is pretty much a simple socket server which sends and receives messages from clients and other servers, so there’s pretty much no limit on what you can do with it.

Now that I think about it, I think more people will want to use this framework to handle MMO instances and etc, so I’ll be adding something like an MMO module to the framework, which would help developers with some of the common tasks. It would be awesome if you could give me a list of things you’d want to see in such a module :).

Regarding game sessions - framework doesn’t care much about how your game networking (game sessions) work, as long as it implements a simple interface. Regarding the uNET HLAPI, you’re actually encouraged to use it (basic game server setup is already written using it).

Regarding the ceveats of using this for an MMO - I don’t see any related to the framework, because there are so many ways in which you can use it.

If I were to make an MMO, I’d use the framework to handle authorization, player profiles, messaging, maybe use the Networking API to write a micro server to handle Auction Houses. I’d probably separate the game into regions (game servers) to handle the load, and use the master server to switch those users between game servers.


To EricMuyser:
Glad to be of help!

  1. I think this point is easier to explain with an example (at some point I’ll finish a video which will hopefully explain it better).
    Let’s say you made a very simple game with uNET, without framework (unity’s tutorial) : player can join the server, walk around and collect the coins. When a player joins, you have no way of knowing who that player is, so you’d have to implement some kind of authentication system, persistent profiles and etc. Master Server Framework aims to help you with that.

With the framework, you use the same game server you made earlier, but now it can connect to the master server, register to the list of available game servers (lobby), identify connected players, change their profiles, allow them to chat or do whatever else you would need. The idea is - you make the game logic, and framework takes care of the rest. Main focus of the framework is not to make the game (gameplay), but to help you set up “infrastructure” easier.

What this means is - you make your game any way you want, with whatever you want.

Adding drops, spells and etc is gameplay related, so framework won’t help you with that.

  1. Your second question also seems to be gameplay related, which framework doesn’t handle. I think you shouldn’t buy the framework yet, and focus making the basic game first. Actually, I have quite a lot of experience with MMO’s, so feel free to send me a message, saying what you want to do (controls, player interactions), and I’ll try to guide you to what you should be doing / focusing on, or what assets could be helpful to you. I don’t want you buying this if you’re not sure you can find it useful :wink:

  2. You can use any kind of serialization you want, framework is not opinionated on the matter. To make the messages small and to make framework compatible with as many platforms as possible, messages are sent as raw bytes or strings. You can turn anything into bytes easily ^_^. In case of the json, you can send it as string and deserialize it on the other end.

alvyxaz

I’m gonna play a bit with it for starters and gradually formulate what will be needed.

What is totally needed is the ability to load-balance by dividing game world into separate servers that player will seamlessly (or not) move through.

  • In my case I need to spawn multiple game servers each running his own Scene corresponded to single area in the world. Some on dedicated machines and some sharing one machine. I need to move player from one Scene (server) to another when he gets to area teleport point so seamlessness is not my case for now. I need these servers to run 24/7 and restart if crushed.
  • Second thing is to instantiate dungeons that feature is obvious to achieve with your product already)
  • Third is some kind of front end servers to load-balance further but thats out of priority.
  • Forth is not directly related to masterserver but, it maybe used? Database server is unavoidable and it would be nice to reuse as much as possible at first stages of development at least.

I’m really looking forward to masterserver, if does its job reliably it will be a life saver product (at least until unet phase 3 comes))

Sooner or later Server Library will come (it is a LLAPI out of unity! Yay!), can you estimate, how hard it would be to separate masterserver from unity? Your points of running unity are valid but still… I will sleep better knowing that such core part of infrastructure is not coped with game engine)

That makes a lot of sense alvyxaz, thank you. So your point is that I should already have my game mostly done and talking to a single server before I worry about picking up your asset to bring the rest into the fold (authentication, persistence, messaging). I guess one of the problems is other assets also include some of that, but they don’t scale. I think what I’ll do is continue, ignore the other asset features like messaging with the intention of possibly adding yours on top later. Thanks again for the help!

Yah per shamsfk’s comment above - what is ideal is a pool of game servers registered to the master server who can be assigned to a game when the player wants to create one. As far as I can see, that’s totally possible with your asset but you haven’t done much around streamlining it. eg.

  • Master server maintains a pool of game servers ready and waiting
  • Client asks master server to connect to a nearby game server. Master server asks game server if player is nearby. If yes, master server grabs a game server in the pool (or creates a new one) and tells it about the client, gets the auth key, sends to the client to connect to game server.

I won’t be building a seamless world like that, but still if that existed I could utilize it for my game - which goes like this:

  • Player connects to master server, master server sends player the details to connect to a game server used as the lobby (there may be multiple lobbies).
  • Player can create a game from within the lobby for other people to join (this is where the above and pooling would come in handy)

to shamsfk

Actually, a month ago, the whole master server was completely unity independent, written as a simple DLL (.NET 4.5). However, after writing documentation for it, I realized that it’s way too tedious to set everything up, and customers might be appalled by it . I wanted to create an almost one-click solution, where you don’t need to have multiple IDE’s open, sharing DLL’s, starting the servers and etc. I realized that master server is unlikely to be a bottle-neck (traffic and game servers are), so there’s not much of a downside of moving everything to Unity (except for .NET 3.5, haha).

I could include into the framework code that would allow you to write unity-independent socket servers, and, if you want, after some refactoring, I might be able to make the master server runnnable both, with Unity and without it

Regarding the database, at this point, all of the framework interactions with database are abstracted (you call an interface implementation, like IAuthDatabase.GetAccount(…)). The implementation provided is with LiteDB (which is an embedded NoSQL db) because it doesn’t require any setup. It’s easy to write implementations for Mongo, MySQL or any database server you might want to use.

By the way, it seems like the feature you’re most interested in is load-balancing and spawning of game server instances. In the near future, I’m planning to release modules as separate assets for a cheaper price. If you’re interested, I could make an asset specifically for load-balancing.

to EricMuyser

Yeah, one of the points of the framework was to make it as decoupled from your game as possible, so, at some point, if you decide to use something different, the core game remains the same. I encourage you to first make something like a basic one-scene prototype, and only then buy the framework to integrate the rest of the functionality. Integrating the framework should be easy :slight_smile:

I chose not to implement servers pool to save server resources, as keeping a number of servers running when there’s no one playing might be wasteful. Though, if I understand this correctly, it wouldn’t be too hard to implement something like that if need arises:

At the provided demo, instead of the pool, a new instance of Unity is started, and player connects to it. As you can see, the process is very fast, and starting the headless Unity instance takes about a second. When the last player leaves, game server terminates itself (it doesn’t have to, you can keep it running). If you don’t terminate the server, you can write a simple matchmaker which, after hitting a “Play” button somewhere, would look for the best suited server (by location), and that would work pretty much like pooling you wanted :slight_smile:

alvyxaz

Hi! Cool. That is awesome! I have several more questions)

  • Is source code fully available? (It is apparently)

  • Is it nice?))

  • Can you include (and maintain) standalone version? (I suppose most of devs would at some point prefer to decouple)

  • On the auth side what about encryption? AES, RSA?

  • Can you provide some example of user “jumping” from game server to game server at its will? Like button to jump to server A and it has a button to jump to server B) something of that kind.

About extensions - these are always welcome!) If they are good ones)

shamsfk

Yeah, as you’ve figured it out, the source code is fully available. I’d say the source code is easy to understand and follow (my colleagues seem to agree with me :slight_smile: ).

Regarding the standalone version, I need to spend some more time on it to see if it’s not too much of a hassle to maintain both versions, and if introducing a standalone version wouldn’t make it more difficult for Unity users to use.

Regarding the auth encryption, a few days ago I’ve implemented RSA encryption, but the changes are not yet in the asset store. It will be submitted with the v1.01 update (see description), which mainly focuses on improving authentication.

About the example, yeah, I can get the example done within the next couple of days (I’m working on improving file hierarchy and module decoupling while there aren’t too many purchases). I’ll get back to you once it’s done ;).

On my way to atm… :slight_smile:

You can go with just an instruction doc on how to decouple it will suffice because need to decouple means that you made a game already and going production so a little effort is not too much of a burden (in terms of that you already gone through so much and most likely capable of doing it))

Example would be very welcome.

Hello!

Is it possible to let player hosts game servers (localy in their house or from the cloud) with this frame, i guess it is from reading this but then i saw the “Spawner Servers module”, but i assume this is optional to use :slight_smile:

Yes, you can let players host game servers - they could then be registered to Master Server and their server would be visible within the lobby ;).

However, I need to note that regular issues related to NAT will still remain (framework does not provide any means to do NAT Punch-through). What this means is that when a player who is under a router (doesn’t have a unique IP) hosts a game, other players might not be able to access it. Unity encourages you to use their Relay services to solve this issue, but it costs money (framework was designed to avoid using unity services, their matchmaker and etc)

This is one of the reasons why Spawner Server module was created - it removes the need of NAT punch-through, allows mobile / web players to create rooms without hosting them, and it solves an issue with players having too much authority (if they host a game server, they might write a hack, for example, to destroy player items, as all of the game logic is within their computers).

Though, many room-based games don’t worry about these things and allow players to host games. I guess it’s mainly because there’s no sensitive data, and they don’t care much if some of the users can’t host public games. And there are more ways to solve these issues :slight_smile:

How’s the legacy if somebody from china would connect to my master server in europe?
Is it already possible to connect people worldwide without any laggs? Tahnks. :slight_smile:

Hi!
Legal matters are too wide of a topic, mainly it depends on a content you provide.
And yes it is absolutely possible to connect people from anywhere to anywhere.
But be aware of a latency. There nothing that any framework, protocol, isp or actual hardware can do with it. For example - transatlantic connection will have a ping of no less than 150ms thats pretty much a limitation of a speed of light + infrastructure overheads. How laggy or not is it for you depends solely on your game and it’s dependency on latency.
That said there is always a solution to have regional servers. Naming China - you pretty much Must have a regional server.
Whats great about masterserver is that you can tailor it for your needs, like having a global worldwide master server that will route players to their appropriate regional game servers. (China still might need to be fully regional like even having their own regional master server)