Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Unity Multiplayer Are you separating your client and server code ?

Discussion in 'Multiplayer' started by liortal, Jun 21, 2015.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,544
    Hey,

    Playing around with the new multiplayer (high level) APIs, it feels to me that client & server code are mixed together, which is a bit confusing (to me).

    For example - NetworkManager has callbacks for both client and server.

    I was wondering if anyone is splitting their code to make a more clear separation between client & server, and if so, what are you doing to achieve it ?
     
  2. rob_vld

    rob_vld

    Joined:
    Jul 9, 2013
    Posts:
    184
    Hi... i am doing this!

    Pretty much copying the server init code you have to the client and instead using StartServer using StartClient... when connecting it triggers the logs on the server about not having set a default player prefab but that is about it... nothing else fires... it is all still very confusing...


    Code (CSharp):
    1. public class ManagerNetwork : NetworkManager
    2.     {
    3.     private void Start()
    4.         {
    5.         networkAddress = "127.0.0.1";
    6.         networkPort    = 22001;
    7.         maxConnections = 1000;
    8.         sendPeerInfo   = false;
    9.  
    10.         connectionConfig.AddChannel( QosType.Reliable );
    11.  
    12.         StartServer( );
    13.        }
    14.    }
     
  3. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    I am making very different projects for client and server, as their respective jobs bear little in common. Because of that, I have had to ditch the HLAPI as it requires both client and server to be the same. The LLAPI is working very well, although it could use a few extras to help with things like lag and jitter
     
  4. rob_vld

    rob_vld

    Joined:
    Jul 9, 2013
    Posts:
    184
    I see no reason why this code can't be seperated... and the LLAPI is not something i want to touch...
     
  5. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    You'd have to ask the uNet devs why they have to be the same.
     
  6. rob_vld

    rob_vld

    Joined:
    Jul 9, 2013
    Posts:
    184
    *awaits a dev response* :)
     
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,544
    Let's see now ! @seanr