Example #1
0
        public ServerGame(ServerGameContext ctx)
        {
            Assert.IsNotNull(ctx.World);
            world = ctx.World;

            //var networkInterface = new LidgrenServerNetworkInterface(ctx.Settings.Port, ctx.LagSettings);
            var networkInterface = new LiteNetServerNetworkInterface(ctx.Port);

            server = new CubeServer(ctx.World, networkInterface, ctx.ReplicaManagerSettings);

            server.NetworkInterface.ApproveConnection        += OnApproveConnection;
            server.NetworkInterface.NewConnectionEstablished += OnNewIncomingConnection;
            server.NetworkInterface.DisconnectNotification   += OnDisconnectNotification;
            server.Reactor.AddMessageHandler((byte)MessageId.LoadSceneDone, OnLoadSceneDone);
        }
Example #2
0
        public void StartServer()
        {
            if (GameServer != null)
            {
                return;
            }

            var serverWorldGO = new GameObject("Server World");
            var serverWorld   = serverWorldGO.AddComponent <World>();

            var ctx = new ServerGameContext()
            {
                World = serverWorld,
                Port  = Port,
                ReplicaManagerSettings = ReplicaManagerSettings,
                LagSettings            = LagSettings
            };

            GameServer = CreateServer(ctx);

            OnServerRunning();
        }
Example #3
0
 protected virtual ServerGame CreateServer(ServerGameContext ctx)
 {
     return(new ServerGame(ctx));
 }