private bool DataHandle(PackageUserToken token) { if (token.Pakcage.OutgoingPackage(out byte[] data)) { //处理数据 if (Handler.DataHandle(token, ref data, ActionExecuter)) { var senddata = DataPackage.PackData(data); token.SendEventArgs.SetBuffer(senddata, 0, senddata.Length); SendAsync(token); //发送数据 return(true); } } return(false); }
/// <summary> /// 处理请求 /// </summary> protected override void OnReceiveSuccess(AsyncUserToken usertoken) { base.OnReceiveSuccess(usertoken); PackageUserToken token = usertoken as PackageUserToken; try { token.Pakcage.IncommingData(token.ReceiveEventArgs.Buffer, token.ReceiveEventArgs.Offset, token.ReceiveEventArgs.BytesTransferred); if (!DataHandle(token)) { ReceiveAsync(token); } } catch (Exception err) { Notify(NotifyType.Error, err.Message + ", " + (err.InnerException == null ? "" : err.InnerException.Message), this); } }