Search Unity

Can the MasterServer be used by proprietary server side code

Discussion in 'Multiplayer' started by SixTimesNothing, Oct 5, 2008.

  1. SixTimesNothing

    SixTimesNothing

    Joined:
    Dec 26, 2007
    Posts:
    167
    Is it possible to use the MasterServer's functionality, NAT punchthrough in particular, for non-Unity applications such as server side code being used to run Unity games? i.e. where Unity is being used as the client application and proprietary software is being used as a server.

    I'm trying to get a Unity client to talk to a server application (written in Mono/C#) via a TCP socket connection. It is basically working, but without having something like the MasterServer as a facilitator it's extremely limited. In fact it doesn't really like to talk to anything beyond my local ip address. :(

    It's become pretty clear that simply adding UnityEngine.dll as an assembly reference doesn't work (...and for a minute there I thought I was so clever...)

    This makes me wonder how Thomas has dealt with these kind of issues in his Unity implementation of SmartFoxServer...
     
  2. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Unfortunately, you have to understand how networking works in its entirity to fully appreciate the answer to that question. You can write your own facilitator if you like and you can also write your own code to perform the NAT punch through (not easy). SmartFox has its own way of handling these isses, actually it has a few different built in ways to handle this issue.

    You can even use a multi-tier network model where you use Unity as the first tier, SmartFox as the second tier and your network model as the third tier, all of which is doable.

    The question you need to ask yourself, is what is the end goal. Less than 16 players, less than 64 players or more than 100 players. Networking is just the tip of the iceburg when regards to creating a multiplayer game. It also depends on how much network chatter you plan on having.

    Start by using Unity's built in model, it is already setup and configured for you, just make the calls to it and handle the answers to those calls. This should get you started.
    HTH
     
  3. SixTimesNothing

    SixTimesNothing

    Joined:
    Dec 26, 2007
    Posts:
    167
    Thanks for your response. Admittedly my networking knowledge isn't quite good enough to write my own facilitator, and I'm beginning to think it would be a waste of time anyway, considering both Unity and SmartFoxServer already provide that functionality.

    I already have a working networking solution running inside Unity (i.e. using Unity as both server and client), but the lack of scaleability in that solution concerns me, hence why I was trying to move everything that didn't really need to be on a Unity game server (MySQL database integration, chat, writing log files, etc.) into a separate application. There was no particularly good reason to go with a Mono/C# server application besides not having to rewrite 2000+ lines of code in a different language...

    I guess the best direction to go from here would be to switch to SmartFoxServer Pro, and rewrite all of the database integration code as server side extensions for that. If SmartFoxServer can handle all of that, there would be no need for a third tier running on proprietary code.

    FYI - The networking requirements for the project involve only about 16 players per zone, however each player needs to control anywhere up to 12 units (though the average will be less - more like 6 or 7). Plus there will be at least as many NPC units as there are player controlled units - hence the server has to handle in excess of 200 units, even though each individual player will only need to see and receive updates from a lot less - maybe 30-40. Also, considering the scale of the game, small changes or inconsistencies in unit positions can be safely ignored and updates can be sent over the network far less frequently than most multiplayer games.

    The ideal solution would be to have a headless Unity instance running as a game server for each zone, with SmartFoxServer handling database calls, chat, etc. for multiple zones. Although initially, I am only aiming to get a single zone up and running.