//public event EventHandler<Player.Player> RefreshMonitoredObjs; /// <summary> /// Kick off the game thread /// </summary> /// <param name="server"></param> /// <param name="log"></param> /// <param name="baseObjid"></param> /// <param name="system"></param> public DPGameRunner(DPServer server, ILogController log, uint baseObjid, StarSystem system) { Server = server; Log = log; _baseObjid = baseObjid; _lastAllocatedObjid = baseObjid; System = system; foreach (var s in system.Solars) { Objects[s.Key] = s.Value; s.Value.Runner = this; if (s.Value.Loadout != null) { RefreshObjs += s.Value.HandleTimerEvent; //AddTimer(s.Value); } } // Start the game simulation thread var gameThread = new Thread(GameThreadRun); gameThread.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="CustomContext" /> class. /// </summary> public CustomContext(bool headless, LogSettings lset) { if (_currContext == null) { _currContext = this; } //merge with server settings? var cfgFile = new FLDataFile("flopenserver.cfg", false); AccountDir = cfgFile.GetSetting("server", "acct_path").Str(0); if (AccountDir == "") { AccountDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\My Games\Freelancer\Accts\MultiPlayer"; } _logger = new Logger(lset.LogToFile); _logger.LogMask[(int)LogType.ERROR] = true; _logger.LogMask[(int)LogType.GENERAL] = true; _logger.LogMask[(int)LogType.DPLAY_MSG] = lset.LogDPlay; _logger.LogMask[(int)LogType.FL_MSG] = lset.LogFLMsg; _logger.LogMask[(int)LogType.FL_MSG2] = lset.LogFLMsg2; if (headless) { _server = new DPServer(_logger); } else { (new ControlWindow()).Show(); } }
public void StopServer() { if (_server != null) { _server.Dispose(); _server = null; } _logger.AddLog(LogType.GENERAL, "Server stopped"); }
/// <summary> /// A new directplay server listening on the specified port. /// </summary> /// <param name="server"></param> /// <param name="log"></param> /// <param name="port">The port to listen to connections on</param> public DirectPlayServer(DPServer server, ILogController log, int port) { _log = log; // Apply iocntl to ignore ICMP responses from hosts when we send them // traffic otherwise the socket chucks and exception and dies. Ignore this // under mono. // Start listening for traffic socket = new UdpListener(port); //socket.Client.Client.IOControl((IOControlCode) SIO_UDP_CONNRESET, new byte[] {0, 0, 0, 0}, null); Task.Factory.StartNew(async() => { while (true) { Received received = await socket.Receive(); ProcessPktFromClient(received.Message, received.Sender); } }); }
public void StartServer() { _server = new DPServer(_logger); }