internal void AdvertiseInterator(IInteractor interactor, InteractorAdvertisement message) { foreach (var i in _repository) { if (i.Id != interactor.Id) { i.SendMessage(message); } } }
private void RemoveInteractor(IInteractor interactor) { _repository.Remove(interactor); var leaveMessage = new InteractorAdvertisement(interactor.User, interactor.Address, false); foreach (var existingInteractor in _repository) { existingInteractor.SendMessage(leaveMessage); } }
internal void OpenInteractor(IInteractor interactor) { Log.Debug($"Opening interactor {interactor}."); var joinMessage = new InteractorAdvertisement(interactor.User, interactor.Address, true); var existingJoinMessages = new List <InteractorAdvertisement>(); foreach (var existingInteractor in _repository) { existingInteractor.SendMessage(joinMessage); existingJoinMessages.Add(new InteractorAdvertisement(existingInteractor.User, existingInteractor.Address, true)); } _repository.Add(interactor); interactor.Start(); foreach (var message in existingJoinMessages) { interactor.SendMessage(message); } }
private void RaiseOnInteractorAdvertisement(InteractorAdvertisement message) { OnInteractorAdvertisement?.Invoke(this, new InteractorAvertisementEventArgs(message.User, message.Address, message.IsJoining)); }