Пример #1
0
 /// <summary>
 /// 通道关闭
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ChannelClosing(object sender, EventArgs e)
 {
     try
     {
         IWcfCallback callback = sender as IWcfCallback;
         if (callback == null)
         {
             return;
         }
         if (_context != null && _context.GetCallback() == callback && !_context.IsClosed)
         {
             _context.IsClosed = true;
             try
             {
                 if (OnClosing != null)
                 {
                     //业务层通知
                     OnClosing(_context, _context.RemoteAddress);
                 }
             }
             catch (Exception er)
             {
                 TraceLog.WriteError("Business notify closing error:{0}", er);
             }
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("ChannelClosing:{0}", ex);
     }
 }
Пример #2
0
 private bool NotifyChannelReceive(ChannelContext context, string param, byte[] buffer)
 {
     //并发
     lock (_instance)
     {
         if (context != null && context.IsConnect)
         {
             try
             {
                 var callback = context.GetCallback();
                 if (callback == null)
                 {
                     return(false);
                 }
                 callback.Receive(param, buffer);
                 return(true);
             }
             catch (Exception ex)
             {
                 context.IsClosed = true;
                 TraceLog.WriteError("Notify:{0} {1}", param, ex);
             }
         }
     }
     return(false);
 }
Пример #3
0
 private bool NotifyChannelReceive(ChannelContext context, string param, byte[] buffer)
 {
     //并发
     lock (_instance)
     {
         if (context != null && context.IsConnect)
         {
             try
             {
                 var callback = context.GetCallback();
                 if (callback == null)
                 {
                     return false;
                 }
                 callback.Receive(param, buffer);
                 return true;
             }
             catch (Exception ex)
             {
                 context.IsClosed = true;
                 TraceLog.WriteError("Notify:{0} {1}", param, ex);
             }
         }
     }
     return false;
 }