Exemplo n.º 1
0
        private void FireEvent(MonitorEvents ev, string endpoint, ZmqError error)
        {
            try
            {
                var _event = this.SocketEvent;

                if (_event != null)
                {
                    _event(this, new MonitorEventArgs()
                    {
                        Event    = ev,
                        Endpoint = endpoint,
                        Error    = error
                    });
                }
            }
            catch (Exception) { }
        }
Exemplo n.º 2
0
		private void FireEvent(MonitorEvents ev, string endpoint, ZmqError error)
		{
			try
			{
				var _event = this.SocketEvent;

				if (_event != null)
				{
					_event(this, new MonitorEventArgs()
					{
						Event = ev,
						Endpoint = endpoint,
						Error = error
					});
				}
			}
			catch (Exception) { }
		}
Exemplo n.º 3
0
		private void EventsWorker()
		{
			try
			{
				while (!_disposed)
				{
					var binary = _pairSocket.Recv();

					if (binary == null || binary.Length == 0) continue;

					var ev = (MonitorEvents) BitConverter.ToUInt16(binary, 0);
					int val = 0;

					if (binary.Length > sizeof (UInt16))
					{
						val = BitConverter.ToInt32(binary, sizeof(UInt16));
					}

					ZmqError error = null;
					var address = "";

					switch (ev)
					{
						case MonitorEvents.BindFailed:
						case MonitorEvents.AcceptFailed:
						case MonitorEvents.CloseFailed:
							address = _pairSocket.RecvString();
							error = new ZmqError(val);
							break;
						case MonitorEvents.MonitorStopped:
							break;
						default:
							address = _pairSocket.RecvString();
							break;
					}

					FireEvent(ev, address, error);
				}
			}
			catch (ZmqException ex)
			{
				if (ex.ZmqErrorCode != ZmqErrorCode.ETERM)
				{
					if (LogAdapter.LogEnabled)
					{
						LogAdapter.LogError("Monitor", ex.ToString());
					}
				}
			}
			catch (Exception e)
			{
				if (LogAdapter.LogEnabled)
				{
					LogAdapter.LogError("Monitor", e.ToString());
				}
			}
			finally
			{
				this.Dispose();
			}
		}
Exemplo n.º 4
0
        private void EventsWorker()
        {
            try
            {
                while (!_disposed)
                {
                    var binary = _pairSocket.Recv();

                    if (binary == null || binary.Length == 0)
                    {
                        continue;
                    }

                    var ev  = (MonitorEvents)BitConverter.ToUInt16(binary, 0);
                    int val = 0;

                    if (binary.Length > sizeof(UInt16))
                    {
                        val = BitConverter.ToInt32(binary, sizeof(UInt16));
                    }

                    ZmqError error   = null;
                    var      address = "";

                    switch (ev)
                    {
                    case MonitorEvents.BindFailed:
                    case MonitorEvents.AcceptFailed:
                    case MonitorEvents.CloseFailed:
                        address = _pairSocket.RecvString();
                        error   = new ZmqError(val);
                        break;

                    case MonitorEvents.MonitorStopped:
                        break;

                    default:
                        address = _pairSocket.RecvString();
                        break;
                    }

                    FireEvent(ev, address, error);
                }
            }
            catch (ZmqException ex)
            {
                if (ex.ZmqErrorCode != ZmqErrorCode.ETERM)
                {
                    if (LogAdapter.LogEnabled)
                    {
                        LogAdapter.LogError("Monitor", ex.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                if (LogAdapter.LogEnabled)
                {
                    LogAdapter.LogError("Monitor", e.ToString());
                }
            }
            finally
            {
                this.Dispose();
            }
        }