Exemple #1
0
        /// <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)
        {
            this.server = server;
            this.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.
#if __MonoCS__
#else
            const int SIO_UDP_CONNRESET = -1744830452;

            // Start listening for traffic
            socket = new UdpClient(port);
            try
            {
                socket.Client.IOControl((IOControlCode)SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 }, null);
            }
            catch
            {
            }
#endif
            socket.BeginReceive(RxFromClient, null);
        }
Exemple #2
0
        /// <summary>
        ///     Kick off the game thread
        /// </summary>
        /// <param name="server"></param>
        /// <param name="log"></param>
        public DPGameRunner(DPServer server, ILogController log, uint base_objid, StarSystem system)
        {
            Server              = server;
            this.Log            = log;
            this._baseObjid     = base_objid;
            _lastAllocatedObjid = base_objid;
            this.system         = system;

            foreach (var s in system.Solars)
            {
                Objects[s.Key] = s.Value;
                s.Value.Runner = this;
                if (s.Value.Loadout != null)
                {
                    AddTimer(s.Value);
                }
            }


            // Start the game simulation thread
            var game_thread = new Thread(GameThreadRun);

            game_thread.Start();
        }