Master Server Kit is a complete library that allows you to host your UNET-based multiplayer game on a dedicated server.

While developing CCG Kit, I found there were no readily available solutions for managing a dedicated server setup with UNET-based games, so I started work on developing my own. Master Server Kit was born out of the realization that such a library could be useful for a wide variety of games.

Why?

If you are using UNET as the networking library for your game, Unity Multiplayer Services are an excellent way to get player-hosted games up and running without worrying about the details of setting up your own server infrastructure. But, sometimes, you just need to host your game on a dedicated server. Consider the following scenarios:

Custom backend: You need to be in total control of your game backend. This could be for a variety of reasons: player authentication, player data storage or advanced matchmaking facilities, increased ability for monitoring or maybe you just have the team and expertise needed and prefer to do everything in-house.

Server-side authoritative game logic: Your game needs to be secure against player hacks. In player-hosted games, one of the clients acts as the server. This means that a malicious client has the potential to alter the outcome of the game. Whether this is important or not will depend on the specifics of your game, but sometimes you really need to be safe against this type of cheats. Running the game logic on an independent, authoritative game server that you control is the best way to ensure that.

Running your game on a dedicated server has therefore several advantages over player-hosted games:

More protection against malicious clients.

No artificial CCU limit.

No need for NAT punch-through or relay servers. Clients are never connected directly to each other but through a dedicated server instead.

You only pay for setting up and maintaining your servers (which can be your own machines or a third-party cloud provider like Digital Ocean).

The main drawback is that, of course, you are in charge of everything. You need to pay for the hosting of your servers (unless you physically own them) and make sure they are always available to your players. As they say:

"With great power comes great responsibility."​

Master Server Kit has been specifically created to help you with this task. We want you to focus on making a great game instead!

Features

Master Server Kit provides the following features:

Player registration and authentication (which can be bypassed if desired).

Guest mode.

Support for both world-based and room-based games.

Matchmaking supporting public and private games. Independent game server instances are dynamically spawned and destroyed as needed.

Zone servers that allow you to distribute the game server load across different machines (useful for load balancing or region-based matchmaking).

Player properties system that can be used for implementing currencies and achievements with persistent storage in a database. Default implementations are provided for SQLite, MongoDB and LiteDB.

Chat with support for public and private messages and an unlimited number of channels.

Complete and extensively documented C# source code. Customers have access to the private repository of the project.

Compatible with games using UNET, including games that use the Network Manager component.

Includes demo that showcases the functionality of the kit.

How does it work?

Players log into the master server, which handles authentication in a secure way (this step can be bypassed if desired).

Once successfully logged into the master server, players can create new matches or join existing ones.

The zone servers register themselves into the master server and provide a flexible way of distributing the server load across different machines. This can be used to implement load balancing and region-based matchmaking mechanisms.

The player's data is persisted into a SQLite/MongoDB/LiteDB database. This can be used to implement currencies and achievements.

The master server, the zone servers and the dynamic game server instances are all separate Unity instances, which you can freely setup on your server or even distribute across different server machines as needed.

As I have been doing with CCG Kit, I plan to release new updates often adding new functionality to the kit. If you have any suggestions, please do not hesitate to let me know! I want the kit to be as generally useful as possible and in that regard consider the community's feedback to be a driving force in its development.

Look cool. Do you have any sample of game logics that are controlled by Master Server?
And, what if I used other suthoritative service like BrainClound to log users in? Can it go with your kit?

Click to expand...

Thank you for your kind words, Gunhi!

Master Server Kit is mostly focused on the backend side of things (i.e., "everything that is not the game itself"). Meaning authentication, player profiles, matchmaking, etc. In that regard, the user is responsible for writing the game logic. The included demo is a complete example showing how all the features work in practice.

Having said that, there are some features (like the chat, which I am currently working on for the next update, or the ability to access the players' storage to save game-specific data) that are also useful for the game itself and I am always going to implement them in the demo so that users have a useful reference on how they can use them in their own games.

I am not familiar with brainCloud, but after looking at their website it seems to me like it should be doable to adapt the kit to use their authentication system. As the kit comes with the complete source code included, you can always make use of just a subset of the features provided and avoid/adapt the rest as appropriate for your use case.

Do you have any document or sample how to sync variables, mecanim .. and so on.
I couldn't find any of them on API page! And you should probably integrate with BrainCloud.

Click to expand...

The goal of Master Server Kit is to help you deploy your UNET-based multiplayer game on a dedicated server, effectively bypassing the need for the relay servers/matchmaking/player-hosted games provided by Unity Services. It really has nothing to do with syncing variables or Mecanim animations; you would do that with UNET in your game code.

Say you have a multiplayer, room-based board game. If you use UNET and Unity Services, games are hosted by one of the players acting as the server and players are connected directly to each other in a peer-to-peer fashion by making use of Unity Services' relay servers and matchmaking. Which may be great already, depending on your requirements! But if you want your games to be hosted on a dedicated server instead (e.g., you need your game logic to be completely authoritative or need to be in total control of your backend; I explain this in more detail in the official documentation), then you have to implement your own matchmaking facilities. This is where Master Server Kit can help you: by providing a centralized matchmaking system so that you do not have to worry about this and can focus on your game instead. Additionally, it provides useful features such as authentication and player data storage.

I am focused on extending the core features provided by the kit (rather than third-party integrations) at the moment, but thank you for your suggestion and noted!

Hello! I have just submitted the first update to Master Server Kit (version 1.01), which implements public and private chats with an unlimited number of channels. I have also added new in-lobby and in-game chats to the included demo as an example on how to use this new feature, as you can see in the following screenshots:

The update should be available on the Asset Store in a few days, but if you would like to have it earlier just contact me privately with your invoice number and I will send it to you.

And version 1.01 is now available on the Asset Store! I am currently working on 1.02, which will provide an easy way to use a different database for storage (as several users expressed interest in having other options than MongoDB). The kit will provide default implementations for SQLite and MongoDB.

Hi. Looking cool.
I have a question: If I want only matchmaking without authentication or database - can I do this with your package?

Thanks in advance.

Click to expand...

Thank you! That is an interesting use case and something that can be definitely done. With a very minor modification to the existing code you could bypass the authentication step today (I would be happy to guide you), but I will also implement an explicit mechanism to do it in the next update.

I would also be interested in having one central server to control matchmaking to avoid unity matchmaking without the need for authentication. Then, the matchmaking could be used to find both player hosted matches and maybe some "official" dedicated game servers.

I would also be interested in having one central server to control matchmaking to avoid unity matchmaking without the need for authentication. Then, the matchmaking could be used to find both player hosted matches and maybe some "official" dedicated game servers.

Click to expand...

Thank you! I just finished the work on supporting different databases for storage and will implement an explicit way to disable authentication next. Both features will be included in the next update.

The latest version of the kit, 1.02, needs the Api Compatibility Level option in Build Settings/Player Settings to be changed from .NET 2.0 Subset to .NET 2.0 (this is required by the default SQLite database implementation). You can find more information here. Please let me know if this helps.

First of all, thank you for your purchase!
The latest version of the kit, 1.02, needs the Api Compatibility Level option in Build Settings/Player Settings to be changed from .NET 2.0 Subset to .NET 2.0 (this is required by the default SQLite database implementation).

Click to expand...

That fixed the problems, thanks for your help. I am will finish going through the documentation and if I have questions, will post them.

That fixed the problems, thanks for your help. I am will finish going through the documentation and if I have questions, will post them.

Click to expand...

That is great to hear, Curtis! Definitely do not hesitate to let me know if you have any questions or run into any issues and I will be happy to help you. In these early stages, feedback is very valuable to me as it helps drive the development of new features and improvements.

Thank you for your reply! But can you make a voice chat case, if possible? Because this is more difficult for most people.

Click to expand...

I will add it to my list of things to research in the future but, as I said, it is not an area I am personally experienced with so I am not in a position to make any promises in this regard. I still think VoIP is a complex enough feature that it probably warrants integrating a specialized, proven solution rather than building your own from scratch.

I will add it to my list of things to research in the future but, as I said, it is not an area I am personally experienced with so I am not in a position to make any promises in this regard. I still think VoIP is a complex enough feature that it probably warrants integrating a specialized, proven solution rather than building your own from scratch.

Thank you for your feedback, LostPanda! Please note the Node.js server is only needed if you want to use MongoDB as the database for storing the players' data (SQLite and LiteDB implementations are also provided, with SQLite being the one used by default). I am currently extending the official documentation with more detailed information on how to get started and a step-by-step tutorial and will let you know once it is online. Admittedly, it can be a bit difficult at first to understand how all the pieces are working together.

Thank you for your feedback, LostPanda! Please note the Node.js server is only needed if you want to use MongoDB as the database for storing the players' data (SQLite and LiteDB implementations are also provided, with SQLite being the one used by default). I am currently extending the official documentation with more detailed information on how to get started and a step-by-step tutorial and will let you know once it is online. Admittedly, it can be a bit difficult at first to understand how all the pieces are working together.

The only way the "This user is already logged in" scenario happens as far as I can tell is if you close the master server without closing all the open game clients first. Which should only happen when testing things locally on your development machine, where several windows are open at the same time and you may close them in the wrong order or too fast, and never in a production environment. Having said that, in the next version I plan to reset the "logged in" state for all the users automatically when launching the master server as a precaution.

The only way the "This user is already logged in" scenario happens as far as I can tell is if you close the master server without closing all the open game clients first. Which should only happen when testing things locally on your development machine, where several windows are open at the same time and you may close them in the wrong order or too fast, and never in a production environment. Having said that, in the next version I plan to reset the "logged in" state for all the users automatically when launching the master server as a precaution.

Quick question: Which server does chat operate on? I'm assuming the master server. Also is the matchmaking custom or can we leverage UNET's matchmaker?

Click to expand...

Thank you!

The chat is an independent server component, so it can be plugged into both the master server and the game server. The accompanying demo exemplifies this by using a general chat in the lobby screen (master server) where all the connected players can communicate and a game-specific one in the game screen (game server) that is limited to the players connected to that specific game/match/room.

The matchmaking is completely custom. It is not possible to leverage the one provided by Unity Services because it is built around their relay servers and player-hosted games, while the one in Master Server Kit is specifically built for dedicated server scenarios. Having said that, it provides very similar functionality.

Hey, sorry if I'm not a professional, but we are using .net framework in this kit, so how exactly were we able to host it on linux?

Click to expand...

You can build a Unity project for Linux. I do this with the accompanying demo (in headless mode, meaning no graphics which is particularly convenient for a server), which I host on a Digital Ocean VPS running Ubuntu 16.04.

This is just what I want for months! Great job! I've bought it without hesistation.
And: Could you give a step-by-step tutorial about how to turn an existing game into Master Server status? I think this is a common question. Thank you.

I love your asset so much, that I'm trying to figure it out even it's my first day to look at it.
Aside from the [Master Server Kit option missing] issue above, I encountered another one like in the picture, do you have any idea?
Actually in the screenshots you can see there are already right folders aside them.

I am currently working on the integration of Master Server Kit in CCG Kit (which uses UNET and Unity Services) and I definitely plan to add more information to the official documentation about how it can be done. I hope it will be useful for all the users that are currently leveraging UNET's high-level API together with the matchmaking facilities provided by Unity Services in their games and are interested in migrating to Master Server Kit (it is easy to do and implies no changes in the game logic, but mostly in the matchmaking calls). Please note that help with programming the multiplayer logic of the game itself is outside the scope of Master Server Kit though, as the kit is focused on game-independent functionality such as authentication, matchmaking and player data storage. In that regard, the game itself is responsibility of the user.

The accompanying demo comes with complete source code included and acts as an official reference on how the functionality of the kit can be used.

You should definitely see the Master Server Kit option in the Window menu after importing the package into your project. Are there any errors on the console? Regarding the "Data folder not found" error, I believe you should try deleting those folders and rebuilding everything (making sure there are no errors in the process).

Hey you did it! This is awesome! I was so excited when you started talking about this a while back super glad to see it's set up right, will certainly be checking this out and recommending it to people for other projects, it looks perfect.

Hey you did it! This is awesome! I was so excited when you started talking about this a while back super glad to see it's set up right, will certainly be checking this out and recommending it to people for other projects, it looks perfect.

I am currently working on the integration of Master Server Kit in CCG Kit (which uses UNET and Unity Services) and I definitely plan to add more information to the official documentation about how it can be done. I hope it will be useful for all the users that are currently leveraging UNET's high-level API together with the matchmaking facilities provided by Unity Services in their games and are interested in migrating to Master Server Kit (it is easy to do and implies no changes in the game logic, but mostly in the matchmaking calls). Please note that help with programming the multiplayer logic of the game itself is outside the scope of Master Server Kit though, as the kit is focused on game-independent functionality such as authentication, matchmaking and player data storage. In that regard, the game itself is responsibility of the user.

The accompanying demo comes with complete source code included and acts as an official reference on how the functionality of the kit can be used.

You should definitely see the Master Server Kit option in the Window menu after importing the package into your project. Are there any errors on the console? Regarding the "Data folder not found" error, I believe you should try deleting those folders and rebuilding everything (making sure there are no errors in the process).

Click to expand...

Hey man, thank you for the reply!

1. For the [Master Server Kit option missing] issue, there was some fatal errors shown in red, but after some jibber jabber operations, it went away. But I bet the issue isn't a special one, and I'll let you know if I see it again.

2. For the [integration tutorial], for me the most important part is about building game server. When using UNET, basically I've written the "server" logic in the game. But is there any additional stuff that I should do to build a game server? Should I include the game client scenes when building game server?

3. The error "there should be 'MasterServer_Data' folder next to the executable" happens when I build with "window=>Master Game Kit=>Build All". Please note I'm using 5.4.3, and if I build the scenes separately, the build won't have such an issue.

1. For the [Master Server Kit option missing] issue, there was some fatal errors shown in red, but after some jibber jabber operations, it went away. But I bet the issue isn't a special one, and I'll let you know if I see it again.

Click to expand...

Happy to hear that! Definitely let me know the details if this is something that you can reproduce consistently.

2. For the [integration tutorial], for me the most important part is about building game server. When using UNET, basically I've written the "server" logic in the game. But is there any additional stuff that I should do to build a game server? Should I include the game client scenes when building game server?

Click to expand...

It really depends on how the game is written but, generally speaking, the game server will be a scene with no graphics at all with the sole responsibility of managing the logic of a game/match/room, so no client-related scenes should be needed at all (you can see this is what I am doing in the game server of the accompanying demo). The kit provides you with two base classes, GameClient and GameServer, that you can subclass to implement any additional functionality specific to your game. Please feel free to contact me privately with more information about your game so I can point you to more specific parts of the kit and the demo.

3. The error "there should be 'MasterServer_Data' folder next to the executable" happens when I build with "window=>Master Game Kit=>Build All". Please note I'm using 5.4.3, and if I build the scenes separately, the build won't have such an issue.

Click to expand...

The menu option generates 64-bit Windows binaries by default. Maybe that is the cause of your issues? You can change the platform in Demo/Scripts/Editor/Builder.cs.

It really depends on how the game is written but, generally speaking, the game server will be a scene with no graphics at all with the sole responsibility of managing the logic of a game/match/room, so no client-related scenes should be needed at all (you can see this is what I am doing in the game server of the accompanying demo). The kit provides you with two base classes, GameClient and GameServer, that you can subclass to implement any additional functionality specific to your game. Please feel free to contact me privately with more information about your game so I can point you to more specific parts of the kit and the demo.

Click to expand...

The original game was a typical UNET game. Each player can gain resource, and can use the resource to spawn soldiers. So the case was that one player is both a client and a server(which manages player resource amount, and soldier HP's), and other player are clients.
The ideal result I get with Master Server Kit will be:
1. I get a game server build from the project (I kinda know the process, but want to know if the game senes should be included when building this. Or if I use the "Build All", is there special configuration I should do?)
2. The game server runs on an AWS machine, and is managed by the Master Server(this part you've explained in the docs)
3. The game server handles resource amount, and soldier HP's. (the HOW part I want to know about)
4. From there on , no players device should manage the important stuff like HP any more, they don't act as "server" no more.(the HOW part I want to know about)

The menu option generates 64-bit Windows binaries by default. Maybe that is the cause of your issues? You can change the platform in Demo/Scripts/Editor/Builder.cs.

Click to expand...

I'm also using a Win64 machine, so that should not be the cause? Tomorrow I'll restart and see whether that helps.
Also, since the docs are not fully implemented, I may want to read your fabulous code, which would be an excellent learning source to me! Which class should I start from? Could you briefly talk about the classes?
Thanks again!

The original game was a typical UNET game. Each player can gain resource, and can use the resource to spawn soldiers. So the case was that one player is both a client and a server(which manages player resource amount, and soldier HP's), and other player are clients.
The ideal result I get with Master Server Kit will be:
1. I get a game server build from the project (I kinda know the process, but want to know if the game senes should be included when building this. Or if I use the "Build All", is there special configuration I should do?)
2. The game server runs on an AWS machine, and is managed by the Master Server(this part you've explained in the docs)
3. The game server handles resource amount, and soldier HP's. (the HOW part I want to know about)
4. From there on , no players device should manage the important stuff like HP any more, they don't act as "server" no more.(the HOW part I want to know about)

Click to expand...

You are asking about game-specific logic (resources, HP, etc.). It is really up to you how you decide to implement it; as I said before Master Server Kit will not help you with that. It is focused on game-independent functionality like authentication, matchmaking and player data storage.

Also, since the docs are not fully implemented, I may want to read your fabulous code, which would be an excellent learning source to me! Which class should I start from? Could you briefly talk about the classes?
Thanks again!

Click to expand...

I am currently working on adding more information to the official documentation discussing the code architecture and the main classes in more detail. The source code is documented and the best starting point is probably the MasterServer class, as it is the one in charge of the matchmaking logic and spawning/destroying game server instances as appropriate.

You are asking about game-specific logic (resources, HP, etc.). It is really up to you how you decide to implement it; as I said before Master Server Kit will not help you with that. It is focused on game-independent functionality like authentication, matchmaking and player data storage.

Click to expand...

I guess why I asked this was : is this "game server" in the Kit only handling data transferring? Like the MM server used by UNET? (by default) Or was it designed to act as a "headless" authoritative client (like the client creating the game) and can handle the logic with no graphics?

I am currently working on adding more information to the official documentation discussing the code architecture and the main classes in more detail. The source code is documented and the best starting point is probably the MasterServer class, as it is the one in charge of the matchmaking logic and spawning/destroying game server instances as appropriate.

Click to expand...

This is definitely great news! Guess these days will be crazy and busy, but I think this is really something, and it could help a lot of people like myself!

To explain my question further, let's look at this button in UNET below. Let's imagine: if the MSK(master server kit) can make a game server that is basically running as this "Server Only"(which will automatically handle all the important information for the typical UNET games) . Then integrating would be simpler and faster than ever, wouldn't it?

I guess why I asked this was : is this "game server" in the Kit only handling data transferring? Like the MM server used by UNET? (by default) Or was it designed to act as a "headless" authoritative client (like the client creating the game) and can handle the logic with no graphics?

Click to expand...

Oh, I see what you mean. The idea with a dedicated server setup is generally for the game server to be authoritative and drive the logic of your game, but I guess you could technically do something similar to player-hosted games and use the game server only as the medium through which players communicate between themselves? After all, you are in complete control of what goes in your game's game server.

Oops...

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.