示例#1
0
        public override void ActivateOptions()
        {
            base.ActivateOptions();

            if (Hostname == null || ServerName == null || UserName == null || Password == null || To == null)
            {
                ErrorHandler.Error("Unable to initialize the appender. Some of required parameters are missed. Ensure you set <hostname/>, <serverName/>, <userName/>, <password/> and <to/> parameters.");
                return;
            }

            if (Resource == null)
            {
                var sb = new StringBuilder();
                sb.Append(Environment.MachineName.ToLowerInvariant())
                    .Append('.')
                    .Append(Utils.ComputeSHA1Hash(AppDomain.CurrentDomain.BaseDirectory, Encoding.UTF8).Substring(0, 7));

                Resource = sb.ToString();
            }

            _jc = new AsyncJabberClient
            {
                Hostname = Hostname,
                Port = Port,
                ServerName = ServerName,
                UserName = UserName,
                Password = Password,
                Resource = Resource,
                ExProcessor = ex => ErrorHandler.Error("An unhandled error just occurred.", ex),
            };

            _tl = new Timer(OnNextLogin);
            _ts = new Timer(OnNextSend);

            _jc.Disconnected += delegate
            {
                OnNextLogin(null);
            };

            _obs = BufferSize == default(int) ? 10 : BufferSize;
            _to = To.Split(',');
            if (_to.Length == 0)
            {
                ErrorHandler.Error("Unable to initialize the appender. <to/> parameter is empty. You have to provide at least one entry here.");
                return;
            }
            _buffer = new Queue<LoggingEvent>(_obs);

            _initiated = true;

            OnNextLogin(null);
        }
示例#2
0
 private void ThreadPoolOnReadBuffer(AsyncJabberClient asyncJabberClient, SocketAsyncEventArgs e)
 {
     throw new NotImplementedException();
 }