Ejemplo n.º 1
0
        private async void ConfigurationChanged(RaftClusterMemberConfiguration configuration, string name)
        {
            metadata        = new MemberMetadata(configuration.Metadata);
            allowedNetworks = configuration.AllowedNetworks;
            await ChangeMembersAsync((in MutableMemberCollection members) =>
            {
                var existingMembers = new HashSet <Uri>();
                //remove members
                foreach (var holder in members)
                {
                    if (configuration.Members.Contains(holder.Member.BaseAddress))
                    {
                        existingMembers.Add(holder.Member.BaseAddress);
                    }
                    else
                    {
                        var member = holder.Remove();
                        MemberRemoved?.Invoke(this, member);
                        member.CancelPendingRequests();
                    }
                }

                //add new members
                foreach (var memberUri in configuration.Members)
                {
                    if (!existingMembers.Contains(memberUri))
                    {
                        var member = CreateMember(memberUri);
                        members.Add(member);
                        MemberAdded?.Invoke(this, member);
                    }
                }

                existingMembers.Clear();
            }).ConfigureAwait(false);
Ejemplo n.º 2
0
        internal void RemoveMember(string data)
        {
            var member = ParseMember(data);

            if (Members.ContainsKey(member.Key))
            {
                Members.Remove(member.Key);

                MemberRemoved?.Invoke(this);
            }
        }
Ejemplo n.º 3
0
 public FarmDispatcher(
     ISetupPollCommand createPoll2Command,
     IPollAnswer raidPollAnswer,
     IEventSetupAnswer eventSetupAnswer,
     MemberAdded memberAdded,
     MemberRemoved memberRemoved
     ) : base()
 {
     base.commands.Add(createPoll2Command);
     base.answers.Add(raidPollAnswer);
     base.answers.Add(eventSetupAnswer);
     base.memberAdded   = memberAdded;
     base.memberRemoved = memberRemoved;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads the <see cref="GuildInfoMessages.RemoveMember"/> message.
        /// </summary>
        /// <param name="r">The stream to read the message from.</param>
        void ReadRemoveMember(BitStream r)
        {
            var name        = r.ReadString();
            var removeCount = _members.RemoveAll(x => StringComparer.OrdinalIgnoreCase.Equals(x.Name, name));

            Debug.Assert(removeCount != 0, "Nobody with the name " + name + " existed in the collection.");
            Debug.Assert(removeCount < 2, "How the hell did we remove more than one item?");

            OnMemberRemoved(name);

            if (MemberRemoved != null)
            {
                MemberRemoved.Raise(this, EventArgsHelper.Create(name));
            }
        }
        void IPresenceChannelManagement.RemoveMember(string data)
        {
            var parsedMember = ParseMember(data);

            if (Members.TryRemove(parsedMember.Key, out T member))
            {
                if (MemberRemoved != null)
                {
                    try
                    {
                        MemberRemoved.Invoke(this, new KeyValuePair <string, T>(parsedMember.Key, member));
                    }
                    catch (Exception e)
                    {
                        _pusher.RaiseChannelError(new MemberRemovedEventHandlerException <T>(parsedMember.Key, member, e));
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles <see cref="GroupInfoMessages.RemoveMember"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to read from.</param>
        void ReadRemoveMember(BitStream bs)
        {
            var name = bs.ReadString();

            if (!_members.Remove(name))
            {
                const string errmsg = "Tried to remove `{0}` from the group member list, but they were not in the list!";
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat(errmsg, name);
                }
                Debug.Fail(string.Format(errmsg, name));
            }

            // Raise events
            OnMemberRemoved(name);

            if (MemberRemoved != null)
            {
                MemberRemoved.Raise(this, EventArgsHelper.Create(name));
            }
        }
Ejemplo n.º 7
0
        public RaidDispatcher(
            IStartCommand startGroupCommand,
            // IConfigureUserCommand startPrivatCommand,
            IHelpCommand helpCommand,
            ICancelCommand cancelCommand,
            IPollAnswer raidPollAnswer,
            ISettingsCommand settingsCommand,
            // ICreateRaidCommand createRaidCommand,
            IIvCommand ivCommand,
            IPokeCommand pokeCommand,
            IGymsCommand gymsCommand,
            MemberRemoved memberRemoved,
            MembersAdded memberAdded,
            IOwnerCommand ownerCommand,
            IUpdateRaidBossCommand updateRaidBossCommand
            )
        {
            this.commands.Add(startGroupCommand);
            // this.commands.Add(startPrivatCommand);
            this.commands.Add(helpCommand);
            this.commands.Add(cancelCommand);

            this.answers.Add(raidPollAnswer);
            this.commands.Add(settingsCommand);
            // this.commands.Add(createRaidCommand);
            this.commands.Add(ivCommand);
            this.commands.Add(gymsCommand);
            this.commands.Add(pokeCommand);
            this.commands.Add(ownerCommand);
            this.commands.Add(updateRaidBossCommand);


            this.memberAdded   = memberAdded;
            this.memberRemoved = memberRemoved;

            helpCommand.RegisterAllCommands(this.commands.Select(x => x.Value).ToList());
        }