public Server(Configuration configuration, GameCore game, bool openOnInit = true, ILogger logger = null) { if (configuration.Port == 0) { configuration.Port = 33132; } MessageProcessor = new ServerNetworkProcessor(this); MessageProcessor.OnMessageSentOrDiscarded += (a, b) => MessagePool.Release(b); GameInstance = new NetworkedGame(FullGameState.Create(game), logger, game.Settings); HookEvents(); SetGame(game); Logger = logger != null ? (ILogger) new ModuleLogger(logger, "Server") : new NullLogger(); Login = new LoginManager(this); Connections = new ConnectionManager(this); Configuration = new InitializedConfiguration(configuration); Timers = new Engine.Core.Timing.Timer.Factory(); ChatHandler = new Chat.ChatServer(this); Logger.Info($"Server Created."); if (openOnInit) { Open(); } }
public NetClient(string connection, ushort port, ILogger logger = null, string password = null, bool connectOnInit = true) { if (logger != null) { Logger = new ModuleLogger(logger, "CLIENT"); } else { Logger = new NullLogger(); } MessageProcessor = new ClientNetworkProcessor(this); GameInstance = new NetworkedGame(null); Chat = new Chat.ChatClient(this); Host = connection; Port = port; Password = password; NetworkClient = new Lidgren.Network.NetClient( new Lidgren.Network.NetPeerConfiguration("MPTANKS") { ConnectionTimeout = 15, AutoFlushSendQueue = false }); SetupNetwork(); if (connectOnInit) { Connect(); } }