Пример #1
0
 /// <summary>
 /// OnSendCallback
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="e"></param>
 protected virtual void OnSendCallback(IConnection connection, SendCallbackEventArgs e)
 {
 }
Пример #2
0
 /// <summary>
 /// fire SendCallback
 /// </summary>
 /// <param name="e"></param>
 private void OnSendCallback(SendCallbackEventArgs e)
 {
     if (e.Status != SendCallbackStatus.Success) e.Packet.SentSize = 0;
     if (this.SendCallback != null) this.SendCallback(this, e);
 }
Пример #3
0
        /// <summary>
        /// OnSendCallback
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="e"></param>
        protected override void OnSendCallback(IConnection connection, SendCallbackEventArgs e)
        {
            base.OnSendCallback(connection, e);

            try { this._handler.OnSendCallback(connection,e); }
            catch (Exception ex) { Log.Trace.Error(ex.Message, ex); }

            var request = e.Packet as Request;
            if (request == null) return;

            if (e.Status == SendCallbackStatus.Success)
            {
                request.CurrConnection = connection;
                request.SentTime = DateTime.UtcNow;
                this.OnSendSucess(connection, request);
                return;
            }

            request.CurrConnection = null;
            request.SentTime = DateTime.MaxValue;

            if (DateTime.UtcNow.Subtract(request.BeginTime).TotalMilliseconds < this._millisecondsSendTimeout)
            {
                this.OnSendFailed(connection, request);
                return;
            }

            //time out
            this.OnSendTimeout(request);

            ThreadPool.QueueUserWorkItem(_ =>
            {
                var rex = new RequestException(RequestException.Errors.PendingSendTimeout);
                try { request.SetException(rex); }
                catch (Exception ex) { Log.Trace.Error(ex.Message, ex); }
            });
        }
Пример #4
0
 public void OnSendCallback(IConnection connection, SendCallbackEventArgs e)
 {
     //throw new NotImplementedException();
     Console.WriteLine("send ok");
 }
Пример #5
0
 /// <summary>
 /// send callback
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="e"></param>
 protected override void OnSendCallback(IConnection connection, SendCallbackEventArgs e)
 {
     base.OnSendCallback(connection, e);
     try { this._handler.OnSendCallback(connection, e); }
     catch (Exception ex) { Log.Trace.Error(ex.Message, ex); }
 }