internal void Handle(object sender, NetMQSocketEventArgs socketEventArgs) { MonitorEvent monitorEvent = MonitorEvent.Read(MonitoringSocket.SocketHandle); if (monitorEvent != null) { switch (monitorEvent.Event) { case SocketEvent.Connected: InvokeEvent(Connected, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (Socket)monitorEvent.Arg)); break; case SocketEvent.ConnectDelayed: InvokeEvent(ConnectDelayed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)monitorEvent.Arg)); break; case SocketEvent.ConnectRetried: InvokeEvent(ConnectRetried, new NetMQMonitorIntervalEventArgs(this, monitorEvent.Addr, (int)monitorEvent.Arg)); break; case SocketEvent.Listening: InvokeEvent(Listening, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (Socket)monitorEvent.Arg)); break; case SocketEvent.BindFailed: InvokeEvent(BindFailed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)monitorEvent.Arg)); break; case SocketEvent.Accepted: InvokeEvent(Accepted, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (Socket)monitorEvent.Arg)); break; case SocketEvent.AcceptFailed: InvokeEvent(AcceptFailed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)monitorEvent.Arg)); break; case SocketEvent.Closed: InvokeEvent(Closed, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (Socket)monitorEvent.Arg)); break; case SocketEvent.CloseFailed: InvokeEvent(CloseFailed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)monitorEvent.Arg)); break; case SocketEvent.Disconnected: InvokeEvent(Disconnected, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (Socket)monitorEvent.Arg)); break; default: throw new Exception("unknown event " + monitorEvent.Event.ToString()); } } }
private void Handle(object sender, NetMQSocketEventArgs socketEventArgs) { var monitorEvent = MonitorEvent.Read(m_monitoringSocket.SocketHandle); T GetArg <T>() => monitorEvent.Arg is T v ? v : throw new ArgumentException($"Command argument must be of type {typeof(T).Name}."); switch (monitorEvent.Event) { case SocketEvents.Connected: InvokeEvent(Connected, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, GetArg <AsyncSocket>(), SocketEvents.Connected)); break; case SocketEvents.ConnectDelayed: InvokeEvent(ConnectDelayed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)GetArg <int>(), SocketEvents.ConnectDelayed)); break; case SocketEvents.ConnectRetried: InvokeEvent(ConnectRetried, new NetMQMonitorIntervalEventArgs(this, monitorEvent.Addr, GetArg <int>(), SocketEvents.ConnectRetried)); break; case SocketEvents.Listening: InvokeEvent(Listening, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, GetArg <AsyncSocket>(), SocketEvents.Listening)); break; case SocketEvents.BindFailed: InvokeEvent(BindFailed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)GetArg <int>(), SocketEvents.BindFailed)); break; case SocketEvents.Accepted: InvokeEvent(Accepted, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, GetArg <AsyncSocket>(), SocketEvents.Accepted)); break; case SocketEvents.AcceptFailed: InvokeEvent(AcceptFailed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)GetArg <int>(), SocketEvents.AcceptFailed)); break; case SocketEvents.Closed: InvokeEvent(Closed, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, GetArg <AsyncSocket>(), SocketEvents.Closed)); break; case SocketEvents.CloseFailed: InvokeEvent(CloseFailed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)GetArg <int>(), SocketEvents.CloseFailed)); break; case SocketEvents.Disconnected: InvokeEvent(Disconnected, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, GetArg <AsyncSocket>(), SocketEvents.Disconnected)); break; default: throw new Exception("unknown event " + monitorEvent.Event); } }
private void Handle(object sender, NetMQSocketEventArgs socketEventArgs) { MonitorEvent monitorEvent = MonitorEvent.Read(this.m_monitoringSocket.SocketHandle); switch (monitorEvent.Event) { case SocketEvents.Connected: this.InvokeEvent(this.Connected, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (AsyncSocket)monitorEvent.Arg, SocketEvents.Connected)); break; case SocketEvents.ConnectDelayed: this.InvokeEvent(this.ConnectDelayed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)monitorEvent.Arg, SocketEvents.ConnectDelayed)); break; case SocketEvents.ConnectRetried: this.InvokeEvent(this.ConnectRetried, new NetMQMonitorIntervalEventArgs(this, monitorEvent.Addr, (int)monitorEvent.Arg, SocketEvents.ConnectRetried)); break; case SocketEvents.Listening: this.InvokeEvent(this.Listening, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (AsyncSocket)monitorEvent.Arg, SocketEvents.Listening)); break; case SocketEvents.BindFailed: this.InvokeEvent(this.BindFailed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)monitorEvent.Arg, SocketEvents.BindFailed)); break; case SocketEvents.Accepted: this.InvokeEvent(this.Accepted, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (AsyncSocket)monitorEvent.Arg, SocketEvents.Accepted)); break; case SocketEvents.AcceptFailed: this.InvokeEvent(this.AcceptFailed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)monitorEvent.Arg, SocketEvents.AcceptFailed)); break; case SocketEvents.Closed: this.InvokeEvent(this.Closed, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (AsyncSocket)monitorEvent.Arg, SocketEvents.Closed)); break; case SocketEvents.CloseFailed: this.InvokeEvent(this.CloseFailed, new NetMQMonitorErrorEventArgs(this, monitorEvent.Addr, (ErrorCode)monitorEvent.Arg, SocketEvents.CloseFailed)); break; case SocketEvents.Disconnected: this.InvokeEvent(this.Disconnected, new NetMQMonitorSocketEventArgs(this, monitorEvent.Addr, (AsyncSocket)monitorEvent.Arg, SocketEvents.Disconnected)); break; default: throw new Exception("unknown event " + monitorEvent.Event); } }