⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipmessagehelper.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Base.Comm
{
    using Imps.Client.Base;
    using System;
    using System.Threading;

    public static class SipMessageHelper
    {
        private static AutoResetEvent _evtSync = new AutoResetEvent(false);

        public static void RaiseAckReceived(SipInviteResponse resp, SipAckRequest ack)
        {
            if (resp == null)
            {
                throw new ArgumentNullException("resp");
            }
            if (ack == null)
            {
                throw new ArgumentNullException("ack");
            }
            RaiseEventInThreadPool<SipAckReceivedEventArgs>(new RaiseMethodWrapper<SipAckReceivedEventArgs>(new RaiseEventDelegate<SipAckReceivedEventArgs>(resp.RaiseAckReceived)), new SipAckReceivedEventArgs(ack));
        }

        public static void RaiseEventInThreadPool<TEventArgs>(RaiseMethodWrapper<TEventArgs> raiser, TEventArgs e) where TEventArgs: EventArgs
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(raiser.WaitProc), e);
            SyncEvent.WaitOne(0x3e8, true);
        }

        public static void RaiseFinalResponseReceived(SipRequest req, SipResponse respReceived)
        {
            if (req == null)
            {
                throw new ArgumentNullException("req");
            }
            if (respReceived == null)
            {
                throw new ArgumentNullException("respReceived");
            }
            SipResponseReceivedEventArgs e = new SipResponseReceivedEventArgs(respReceived);
            RaiseEventInThreadPool<SipResponseReceivedEventArgs>(new RaiseMethodWrapper<SipResponseReceivedEventArgs>(new RaiseEventDelegate<SipResponseReceivedEventArgs>(req.RaiseResponseReceived)), e);
            RaiseEventInThreadPool<SipResponseReceivedEventArgs>(new RaiseMethodWrapper<SipResponseReceivedEventArgs>(new RaiseEventDelegate<SipResponseReceivedEventArgs>(req.RaiseFinalResponseReceived)), e);
        }

        public static void RaiseResponseReceived(SipRequest req, SipResponse respReceived)
        {
            if (req == null)
            {
                throw new ArgumentNullException("req");
            }
            if (respReceived == null)
            {
                throw new ArgumentNullException("respReceived");
            }
            RaiseEventInThreadPool<SipResponseReceivedEventArgs>(new RaiseMethodWrapper<SipResponseReceivedEventArgs>(new RaiseEventDelegate<SipResponseReceivedEventArgs>(req.RaiseResponseReceived)), new SipResponseReceivedEventArgs(respReceived));
        }

        public static void RaiseSendMessageFailed(SipMessageBase msg, Exception exFailed, string explanation, RaiseEventDelegate<SendFailedEventArgs> connRaiseMethod)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }
            SendMessageFailedWrapper wrapper = new SendMessageFailedWrapper(msg, exFailed, explanation, connRaiseMethod);
            ThreadPool.QueueUserWorkItem(new WaitCallback(wrapper.WaitProc));
        }

        public static void RaiseSent(SipMessageBase msg)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }
            RaiseEventInThreadPool<EventArgs>(new RaiseMethodWrapper<EventArgs>(new RaiseEventDelegate<EventArgs>(msg.RaiseSent)), EventArgs.Empty);
        }

        public static void RaiseWaitAckTimeout(SipInviteResponse resp)
        {
            if (resp == null)
            {
                throw new ArgumentNullException("resp");
            }
            RaiseEventInThreadPool<EventArgs>(new RaiseMethodWrapper<EventArgs>(new RaiseEventDelegate<EventArgs>(resp.RaiseWaitAckTimeout)), EventArgs.Empty);
        }

        public static void RaiseWaitResponseTimeout(SipRequest req)
        {
            if (req == null)
            {
                throw new ArgumentNullException("req");
            }
            RaiseEventInThreadPool<EventArgs>(new RaiseMethodWrapper<EventArgs>(new RaiseEventDelegate<EventArgs>(req.RaiseWaitResponseTimeout)), EventArgs.Empty);
        }

        internal static AutoResetEvent SyncEvent
        {
            get
            {
                return _evtSync;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -