示例#1
0
 void ProcessMessageReceived(ThreadedQueue sender, object next)
 {
     object[] args = next as object[];
     try
     {
         ProcessMessageReceived((string)args[0], (DateTime)args[1]);
     }
     catch (Exception ex)
     {
         STEM.Sys.EventLog.WriteEntry(System.Reflection.Assembly.GetEntryAssembly().GetName().Name + ".MessageConnection.ProcessMessageReceived", ex.ToString(), STEM.Sys.EventLog.EventLogEntryType.Error);
     }
 }
        public MessageConnection(System.Net.Sockets.TcpClient client, X509Certificate2 certificate, bool queueReceivedData)
            : base(client, certificate)
        {
            _QueueReceivedData = queueReceivedData;

            if (queueReceivedData)
            {
                _MessageReceivedQueue              = new ThreadedQueue(RemoteAddress + ":" + RemotePort, TimeSpan.FromSeconds(20));
                _MessageReceivedQueue.receiveNext += ProcessMessageReceived;
            }

            _ResponseReceivedQueue              = new ThreadedQueue(RemoteAddress + ":" + RemotePort, TimeSpan.FromSeconds(20));
            _ResponseReceivedQueue.receiveNext += ProcessResponse;
        }
        public MessageConnection(string address, int port, bool sslConnection, bool queueReceivedData, X509Certificate2 certificate, bool autoReconnect = false)
            : base(address, port, sslConnection, certificate, autoReconnect)
        {
            _QueueReceivedData = queueReceivedData;

            if (queueReceivedData)
            {
                _MessageReceivedQueue              = new ThreadedQueue(address + ":" + port, TimeSpan.FromSeconds(20));
                _MessageReceivedQueue.receiveNext += ProcessMessageReceived;
            }

            _ResponseReceivedQueue              = new ThreadedQueue(address + ":" + port, TimeSpan.FromSeconds(20));
            _ResponseReceivedQueue.receiveNext += ProcessResponse;
        }
示例#4
0
        public FileModel()
        {
            this._processingQueue = new ThreadedQueue <IProcessableEvent>("FileModel Processor");

            this._fileMap     = new Dictionary <string, FileData>();
            this._fileMapLock = new object();

            this._directoryListenerMap     = new Dictionary <string, DirectoryListener>();
            this._directoryListenerMapLock = new object();

            this._stopLock = new object();


            this._processingQueue.Start(this.Process);
        }
示例#5
0
        public sealed override void Close()
        {
            base.Close();

            if (_ResponseReceivedQueue != null)
            {
                _ResponseReceivedQueue.Dispose();
                _ResponseReceivedQueue = null;
            }

            List <Message> awaiting = null;

            lock (_AwaitResponse)
            {
                awaiting = _AwaitResponse.Values.ToList();
                _AwaitResponse.Clear();
            }

            foreach (Message ar in awaiting)
            {
                StopWaiting(ar);

                ConnectionLost m = new ConnectionLost(ar.MessageID);

                m.MessageConnection = this;
                m.TimeSent          = m.TimeReceived = DateTime.UtcNow;

                try
                {
                    if (_ReceiveResponse != null)
                    {
                        _ReceiveResponse(this, ar, m);
                    }
                }
                catch { }
            }
        }
        public sealed override void Close()
        {
            base.Close();

            if (_MessageReceivedQueue != null)
            {
                _MessageReceivedQueue.Dispose();
                _MessageReceivedQueue = null;
            }

            if (_ResponseReceivedQueue != null)
            {
                _ResponseReceivedQueue.Dispose();
                _ResponseReceivedQueue = null;
            }

            lock (_AwaitResponse)
            {
                foreach (Message ar in _AwaitResponse.Values.ToList())
                {
                    ConnectionLost m = new ConnectionLost(ar.MessageID);

                    m.MessageConnection = this;
                    m.TimeSent          = m.TimeReceived = DateTime.UtcNow;

                    try
                    {
                        if (_ReceiveResponse != null)
                        {
                            _ReceiveResponse(this, ar, m);
                        }
                    }
                    catch { }
                }
            }
        }
示例#7
0
 public MessageConnection(string address, int port, bool sslConnection, bool autoReconnect = false)
     : base(address, port, sslConnection, autoReconnect)
 {
     _ResponseReceivedQueue              = new ThreadedQueue(address + ":" + port, TimeSpan.FromSeconds(20));
     _ResponseReceivedQueue.receiveNext += ProcessResponse;
 }
示例#8
0
        void ProcessResponse(ThreadedQueue sender, object next)
        {
            object[] args = next as object[];

            new ResponseHandlerThread(this, (Message)args[0], (Message)args[1]);
        }