/// <summary> /// When a communicator's state is changed, this method handles event.. /// </summary> /// <param name="sender">Creator of event</param> /// <param name="e">Event arguments</param> private void Communicator_StateChanged(object sender, CommunicatorStateChangedEventArgs e) { //Process only CommunicationStates.Closed state if (e.Communicator.State != CommunicationStates.Closed) { return; } lock (_communicators) { var connectedCommunicator = FindCommunicator(e.Communicator); if (connectedCommunicator == null) { return; } _communicators.Remove(connectedCommunicator); //Send Reject message for processing message, because communicator is disconnected if (connectedCommunicator.ProcessingMessage != null) { OnResponseReceived( null, new MDSOperationResultMessage { RepliedMessageId = connectedCommunicator.ProcessingMessage.MessageId, Success = false, ResultText = "Communicator of remote application disconnected from server." }); } Logger.Info("A connection closed with remote application: " + Name); } OnCommunicatorDisconnected(e.Communicator); }
/// <summary> /// When state of a communicator changes, this method handles event. /// It is used to remove a communicator from list when it is closed. /// </summary> /// <param name="sender">Sender (ICommunicationManager)</param> /// <param name="e">Event arguments</param> private void Communicator_StateChanged(object sender, CommunicatorStateChangedEventArgs e) { switch (e.Communicator.State) { case CommunicationStates.Closed: RemoveFromCommunicators(e.Communicator.ComminicatorId); break; } }