/// <summary>
        /// Initialize the socket subsystem.
        /// </summary>
        /// <param name="Script">Supplies the main script object.</param>
        /// <returns>True if socket I/O is connected.</returns>
        public static bool Initialize(ACR_ServerCommunicator Script)
        {
            if (Initialized)
                return true;

            try
            {
                RecvfromDelegate = new RecvfromCallout(OnLowLevelReceive);
                RecvfromDelegateHandle = GCHandle.Alloc(RecvfromDelegate);

                try
                {
                    SetRecvfromCallout(Marshal.GetFunctionPointerForDelegate(RecvfromDelegate));
                }
                catch (Exception e)
                {
                    Script.WriteTimestampedLogEntry(String.Format("SocketIo.Initialize: Exception: {0}", e));
                    RecvfromDelegate = null;
                    RecvfromDelegateHandle.Free();
                    throw;
                }
            }
            catch
            {
                return false;
            }

            Initialized = true;
            return true;
        }
        /// <summary>
        /// Initialize the socket subsystem.
        /// </summary>
        /// <returns>True if socket I/O is connected.</returns>
        public static bool Initialize()
        {
            if (Initialized)
                return true;

            try
            {
                RecvfromDelegate = new RecvfromCallout(OnLowLevelReceive);
                RecvfromDelegateHandle = GCHandle.Alloc(RecvfromDelegate);

                try
                {
                    SetRecvfromCallout(Marshal.GetFunctionPointerForDelegate(RecvfromDelegate));
                }
                catch
                {
                    RecvfromDelegate = null;
                    RecvfromDelegateHandle.Free();
                    throw;
                }
            }
            catch
            {
                return false;
            }

            Initialized = true;
            return true;
        }
Beispiel #3
0
        /// <summary>
        /// Initialize the socket subsystem.
        /// </summary>
        /// <param name="Script">Supplies the main script object.</param>
        /// <returns>True if socket I/O is connected.</returns>
        public static bool Initialize(ACR_ServerCommunicator Script)
        {
            if (Initialized)
            {
                return(true);
            }

            try
            {
                RecvfromDelegate       = new RecvfromCallout(OnLowLevelReceive);
                RecvfromDelegateHandle = GCHandle.Alloc(RecvfromDelegate);

                try
                {
                    SetRecvfromCallout(Marshal.GetFunctionPointerForDelegate(RecvfromDelegate));
                }
                catch (Exception e)
                {
                    Script.WriteTimestampedLogEntry(String.Format("SocketIo.Initialize: Exception: {0}", e));
                    RecvfromDelegate = null;
                    RecvfromDelegateHandle.Free();
                    throw;
                }
            }
            catch
            {
                return(false);
            }

            Initialized = true;
            return(true);
        }