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); }
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(); }
protected virtual ServerGame CreateServer(ServerGameContext ctx) { return(new ServerGame(ctx)); }