/// <summary> /// 触发重新发送事件 /// </summary> /// <param name="e">包含事件的参数</param> protected virtual void OnPackageResend(PackageSendEventArgs e) { if (PackageResend != null) { PackageResend(this, e); } }
/// <summary> /// 当数据发送失败时调用 /// </summary> /// <param name="e">包含事件的参数</param> protected virtual void OnPackageSendFailure(PackageSendEventArgs e) { if (PackageSendFailure != null) { PackageSendFailure(this, e); } }
/// <summary> /// 触发重新发送事件 /// </summary> /// <param name="e">包含事件的参数</param> protected virtual void OnPackageResend(PackageSendEventArgs e) { if (PackageResend != null) { PackageResend(this, e); } IpmEvents.OnUdpPackageResend(_ipmClient, e); }
/// <summary> /// 当数据发送失败时调用 /// </summary> /// <param name="e">包含事件的参数</param> protected virtual void OnPackageSendFailure(PackageSendEventArgs e) { if (PackageSendFailure != null) { PackageSendFailure(this, e); } IpmEvents.OnUdpPackageSendFailure(_ipmClient, e); }
/// <summary> /// 触发重新发送事件 /// </summary> /// <param name="e">包含事件的参数</param> protected virtual void OnPackageResend(PackageSendEventArgs e) { if (PackageResend != null) PackageResend(this, e); IpmEvents.OnUdpPackageResend(_ipmClient, e); }
/// <summary> /// 当数据发送失败时调用 /// </summary> /// <param name="e">包含事件的参数</param> protected virtual void OnPackageSendFailure(PackageSendEventArgs e) { if (PackageSendFailure != null) PackageSendFailure(this, e); IpmEvents.OnUdpPackageSendFailure(_ipmClient, e); }
/// <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); }
/// <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); }