Exemplo n.º 1
0
 public BufferedTransport(IEasyGelfLogger logger, ITransport transport)
 {
     new Thread(() =>
         {
             var cancellationToken = cancellationTokenSource.Token;
             try
             {
                 GelfMessage mesage;
                 while (buffer.TryTake(out mesage, -1, cancellationToken))
                 {
                     try
                     {
                         transport.Send(mesage);
                     }
                     catch(Exception exception)
                     {
                         logger.Error("Cannot send message", exception);
                     }
                 }
             }
             catch
             {
                 GelfMessage message;
                 while (buffer.TryTake(out message))
                 {
                     try
                     {
                         transport.Send(message);
                     }
                     catch (Exception exception)
                     {
                         logger.Error("Cannot send message", exception);
                     }
                 }
             }
             transport.Close();
             stopEvent.Set();
         }) {IsBackground = true, Name = "EasyGelf Buffered Transport Thread"}.Start();
 }
Exemplo n.º 2
0
 public void Close()
 {
     _clientTransport.Close();
     _serverTransport.Close();
 }
Exemplo n.º 3
0
 public void Close(bool suppressClosedEvent = true)
 {
     _wrappedTransport.Close(suppressClosedEvent);
 }
Exemplo n.º 4
0
 public void Close(bool suppressClosedEvent = true)
 {
     DefaultLogger.Debug("Closing test transport!");
     _wrappedTransport.Close(suppressClosedEvent);
 }
Exemplo n.º 5
0
 public bool Disconnect()
 {
     return(transport.Close());
 }
Exemplo n.º 6
0
 public void Close()
 {
     _transport.Close();
 }
Exemplo n.º 7
0
        void IManager.OnTransportError(ITransport trans, string err)
        {
            (this as IManager).EmitError(SocketIOErrors.Internal, err);

            if (trans.State == TransportStates.Connecting ||
                trans.State == TransportStates.Opening)
            {
#if !BESTHTTP_DISABLE_WEBSOCKET
                if (trans is WebSocketTransport)
                {
                    trans.Close();

                    // try to fall back
                    Transport = new PollingTransport(this);
                    Transport.Open();
                }
                else // fallback failed
#endif
                    (this as IManager).TryToReconnect();
            }
            else
            {
                trans.Close();
                (this as IManager).TryToReconnect();
            }
        }
Exemplo n.º 8
0
 public void Cleanup()
 {
     m_transport.Close();
     m_heartbeatService.Stop();
 }
        /*private ITransport LoadTransportFromAssembly(string host, int port, String assemblyName, String transportType)
         * {
         *  //Assembly assembly = Assembly.LoadFrom(assemblyName);
         *  Assembly assembly = Assembly.Load(assemblyName);
         *
         *  foreach (Type type in assembly.GetTypes())
         *  {
         *      _log.Debug(String.Format("type = {0}", type));
         *  }
         *
         *  Type transport = assembly.GetType(transportType);
         *
         *  if (transport == null)
         *  {
         *      throw new ArgumentException(
         *          String.Format("Type is not found in assembly. Type={0} Assembly={1}", transportType, assemblyName));
         *
         *  }
         *
         *  _log.Debug("transport = " + transport);
         *  _log.Debug("ctors = " + transport.GetConstructors());
         *
         *  ConstructorInfo info = transport.GetConstructors()[0];
         *  ITransport result = (ITransport)info.Invoke(new object[] { host, port, this });
         *
         *  _log.Debug("transport = " + result);
         *
         *  return result;
         * }*/

        public void Disconnect()
        {
            _transport.Close();
        }