/// <summary> /// Removes the connections of the given conversation owners. /// </summary> /// <param name="conversationOwnerParties">The conversation owners whose connections to remove.</param> /// <returns>The number of connections removed.</returns> protected virtual IList <MessageRouterResult> RemoveConnections(IList <Party> conversationOwnerParties) { IList <MessageRouterResult> messageRouterResults = new List <MessageRouterResult>(); foreach (Party conversationOwnerParty in conversationOwnerParties) { ConnectedParties.TryGetValue(conversationOwnerParty, out Party conversationClientParty); if (ConnectedParties.Remove(conversationOwnerParty)) { if (conversationOwnerParty is PartyWithTimestamps) { (conversationOwnerParty as PartyWithTimestamps).ResetConnectionEstablishedTime(); } if (conversationClientParty is PartyWithTimestamps) { (conversationClientParty as PartyWithTimestamps).ResetConnectionEstablishedTime(); } messageRouterResults.Add(new MessageRouterResult() { Type = MessageRouterResultType.Disconnected, ConversationOwnerParty = conversationOwnerParty, ConversationClientParty = conversationClientParty }); } } return(messageRouterResults); }
public virtual Party GetConnectedCounterpart(Party partyWhoseCounterpartToFind) { Party counterparty = null; if (IsConnected(partyWhoseCounterpartToFind, ConnectionProfile.Client)) { for (int i = 0; i < ConnectedParties.Count; ++i) { if (ConnectedParties.Values.ElementAt(i).Equals(partyWhoseCounterpartToFind)) { counterparty = ConnectedParties.Keys.ElementAt(i); break; } } } else if (IsConnected(partyWhoseCounterpartToFind, ConnectionProfile.Owner)) { ConnectedParties.TryGetValue(partyWhoseCounterpartToFind, out counterparty); } return(counterparty); }