Пример #1
0
        public UsersPanelViewModel(IrcChannel channel, IEventAggregator eventAggregator, IIrcClient ircClient)
        {
            _eventAggregator  = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator));
            _ircClient        = ircClient ?? throw new ArgumentNullException(nameof(ircClient));;
            _userMutedEvent   = _eventAggregator.GetEvent <UserMutedEvent>();
            _userUnmutedEvent = _eventAggregator.GetEvent <UserUnmutedEvent>();

            Channel = channel ?? throw new ArgumentException(nameof(channel));
            ConnectedUsers.CollectionChanged += ConnectedUsersOnCollectionChanged;

            channel.UserJoined        += ChannelOnUserJoined;
            channel.UserLeft          += ChannelOnUserLeft;
            channel.UsersListReceived += ChannelOnUsersListReceived;
        }
Пример #2
0
        private void TryRaiseUserMutedEvents(string eventName, JObject jsonObjectEvent)
        {
            var json            = jsonObjectEvent.ToString();
            var userMutedEvent  = jsonObjectEvent[eventName];
            var mutedEventInfos = ExtractUserToUserEventDTOs(userMutedEvent);

            mutedEventInfos.ForEach(mutedEventInfo =>
            {
                var sourceUser = _factories.CreateUser(mutedEventInfo.Source);
                var targetUser = _factories.CreateUser(mutedEventInfo.Target);

                var timestamp  = long.Parse(mutedEventInfo.CreatedTimestamp);
                var dateOffset = DateTimeOffset.FromUnixTimeMilliseconds(timestamp);

                var accountActivityEvent = new AccountActivityEvent <Tuple <IUser, IUser> >(new Tuple <IUser, IUser>(sourceUser, targetUser))
                {
                    AccountUserId = AccountUserId,
                    EventDate     = dateOffset.UtcDateTime,
                    Json          = json
                };

                if (mutedEventInfo.Type == "mute")
                {
                    var eventArgs = new UserMutedEvent(accountActivityEvent);
                    this.Raise(UserMuted, eventArgs);

                    if (eventArgs.InResultOf == UserMutedRaisedInResultOf.Unknown)
                    {
                        this.Raise(EventKnownButNotFullySupportedReceived, new EventKnownButNotSupported(json, eventArgs));
                    }
                }
                else if (mutedEventInfo.Type == "unmute")
                {
                    var eventArgs = new UserUnmutedEvent(accountActivityEvent);
                    this.Raise(UserUnmuted, eventArgs);

                    if (eventArgs.InResultOf == UserUnmutedRaisedInResultOf.Unknown)
                    {
                        this.Raise(EventKnownButNotFullySupportedReceived, new EventKnownButNotSupported(json, eventArgs));
                    }
                }
                else
                {
                    this.Raise(UnsupportedEventReceived, new UnsupportedMessageReceivedEvent(jsonObjectEvent.ToString()));
                }
            });
        }
 private void UserUnmuted(object sender, UserUnmutedEvent e)
 {
     Console.WriteLine($">>> Account user ({e.UnmutedBy}) has unmuted {e.UnmutedUser}");
 }