コード例 #1
0
 internal void AdvertiseInterator(IInteractor interactor, InteractorAdvertisement message)
 {
     foreach (var i in _repository)
     {
         if (i.Id != interactor.Id)
         {
             i.SendMessage(message);
         }
     }
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 private void RaiseOnInteractorAdvertisement(InteractorAdvertisement message)
 {
     OnInteractorAdvertisement?.Invoke(this, new InteractorAvertisementEventArgs(message.User, message.Address, message.IsJoining));
 }