コード例 #1
0
 /// <summary>
 /// 触发重新发送事件
 /// </summary>
 /// <param name="e">包含事件的参数</param>
 protected virtual void OnPackageResend(PackageSendEventArgs e)
 {
     if (PackageResend != null)
     {
         PackageResend(this, e);
     }
 }
コード例 #2
0
 /// <summary>
 /// 当数据发送失败时调用
 /// </summary>
 /// <param name="e">包含事件的参数</param>
 protected virtual void OnPackageSendFailure(PackageSendEventArgs e)
 {
     if (PackageSendFailure != null)
     {
         PackageSendFailure(this, e);
     }
 }
コード例 #3
0
ファイル: UDPThread.cs プロジェクト: wdearcai/IpMsg.Net
 /// <summary>
 /// 触发重新发送事件
 /// </summary>
 /// <param name="e">包含事件的参数</param>
 protected virtual void OnPackageResend(PackageSendEventArgs e)
 {
     if (PackageResend != null)
     {
         PackageResend(this, e);
     }
     IpmEvents.OnUdpPackageResend(_ipmClient, e);
 }
コード例 #4
0
ファイル: UDPThread.cs プロジェクト: wdearcai/IpMsg.Net
 /// <summary>
 /// 当数据发送失败时调用
 /// </summary>
 /// <param name="e">包含事件的参数</param>
 protected virtual void OnPackageSendFailure(PackageSendEventArgs e)
 {
     if (PackageSendFailure != null)
     {
         PackageSendFailure(this, e);
     }
     IpmEvents.OnUdpPackageSendFailure(_ipmClient, e);
 }
コード例 #5
0
ファイル: UDPThread.cs プロジェクト: iraychen/IpMsg.Net
		/// <summary>
		/// 触发重新发送事件
		/// </summary>
		/// <param name="e">包含事件的参数</param>
		protected virtual void OnPackageResend(PackageSendEventArgs e)
		{
			if (PackageResend != null) PackageResend(this, e);
			IpmEvents.OnUdpPackageResend(_ipmClient, e);
		}
コード例 #6
0
ファイル: UDPThread.cs プロジェクト: iraychen/IpMsg.Net
		/// <summary>
		/// 当数据发送失败时调用
		/// </summary>
		/// <param name="e">包含事件的参数</param>
		protected virtual void OnPackageSendFailure(PackageSendEventArgs e)
		{
			if (PackageSendFailure != null) PackageSendFailure(this, e);
			IpmEvents.OnUdpPackageSendFailure(_ipmClient, e);
		}
コード例 #7
0
ファイル: UDPThread.cs プロジェクト: iraychen/IpMsg.Net
		/// <summary>
		/// 自由线程,检测未发送的数据并发出
		/// </summary>
		void CheckUnConfirmedQueue()
		{
			//异步调用委托
			if (cucqCallpack == null) cucqCallpack = (s) => OnPackageSendFailure(s as PackageSendEventArgs);
			if (resendCallback == null) resendCallback = (s) => OnPackageResend(s as PackageSendEventArgs);

			do
			{
				if (SendList.Count > 0)
				{
					PackedNetworkMessage[] array = null;

					lock (SendList)
					{
						array = SendList.ToArray();
					}
					//挨个重新发送并计数
					Array.ForEach(array, s =>
					{
						s.SendTimes++;
						if (s.SendTimes >= MaxResendTimes)
						{
							//发送失败啊
							PackageSendEventArgs e = new PackageSendEventArgs() { Package = s };
							if (IPMClient.NeedPostMessage)
							{
								IPMClient.SendSynchronizeMessage(cucqCallpack, e);
							}
							else
							{
								OnPackageSendFailure(e);
							}
							SendList.Remove(s);
						}
						else
						{
							//重新发送
							client.Send(s.Data, s.Data.Length, s.RemoteIP);

							PackageSendEventArgs e = new PackageSendEventArgs() { Package = s };
							if (IPMClient.NeedPostMessage)
							{
								IPMClient.SendASynchronizeMessage(resendCallback, e);
							}
							else
							{
								OnPackageResend(e);
							}
						}
					});
				}

				System.Threading.Thread.Sleep(CheckQueueTimeInterval);
			} while (IsInitialized);
		}
コード例 #8
0
        /// <summary>
        /// 自由线程,检测未发送的数据并发出
        /// </summary>
        void CheckUnConfirmedQueue()
        {
            //异步调用委托
            if (cucqCallpack == null)
            {
                cucqCallpack = (s) => OnPackageSendFailure(s as PackageSendEventArgs);
            }
            if (resendCallback == null)
            {
                resendCallback = (s) => OnPackageResend(s as PackageSendEventArgs);
            }

            do
            {
                if (SendList.Count > 0)
                {
                    PackedNetworkMessage[] array = null;

                    lock (SendList)
                    {
                        array = SendList.ToArray();
                    }
                    //挨个重新发送并计数
                    Array.ForEach(array, s =>
                    {
                        s.SendTimes++;
                        if (s.SendTimes >= MaxResendTimes)
                        {
                            //发送失败啊
                            PackageSendEventArgs e = new PackageSendEventArgs()
                            {
                                Package = s
                            };
                            if (IPMClient.NeedPostMessage)
                            {
                                IPMClient.SendSynchronizeMessage(cucqCallpack, e);
                            }
                            else
                            {
                                OnPackageSendFailure(e);
                            }
                            SendList.Remove(s);
                        }
                        else
                        {
                            //重新发送
                            client.Send(s.Data, s.Data.Length, s.RemoteIP);

                            PackageSendEventArgs e = new PackageSendEventArgs()
                            {
                                Package = s
                            };
                            if (IPMClient.NeedPostMessage)
                            {
                                IPMClient.SendASynchronizeMessage(resendCallback, e);
                            }
                            else
                            {
                                OnPackageResend(e);
                            }
                        }
                    });
                }

                System.Threading.Thread.Sleep(CheckQueueTimeInterval);
            } while (IsInitialized);
        }