private async void Gateway_PresenceUpdated(object sender, GatewayEventArgs <Presence> e)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                      () =>
            {
                if (e.EventData.User.Id == profile.user.Id)
                {
                    if (e.EventData.Game != null)
                    {
                        var game = e.EventData.Game;
                        richPresence.GameContent = game;
                        richPresence.Visibility  = Visibility.Visible;
                    }
                    else
                    {
                        richPresence.Visibility = Visibility.Collapsed;
                    }

                    if (e.EventData.Status != null && e.EventData.Status != "invisible")
                    {
                        rectangle.Fill = (SolidColorBrush)App.Current.Resources[e.EventData.Status];
                    }
                    else if (e.EventData.Status == "invisible")
                    {
                        rectangle.Fill = (SolidColorBrush)App.Current.Resources["offline"];
                    }
                    UpdateBorderColor();
                }
            });
        }
Example #2
0
 private static void Gateway_VoiceStateUpdated(object sender, GatewayEventArgs <VoiceState> e)
 {
     try
     {
         if (e.EventData.UserId == LocalState.CurrentUser.Id)
         {
             LocalState.VoiceState = e.EventData;
             if (String.IsNullOrEmpty(e.EventData.ChannelId))
             {
                 AudioManager.PlaySoundEffect("voicedc");
             }
         }
         else if (e.EventData.ChannelId == LocalState.VoiceState.ChannelId)
         {
             AudioManager.PlaySoundEffect("userjoin");
         }
         else if (LocalState.VoiceDict.ContainsKey(e.EventData.UserId) && LocalState.VoiceDict[e.EventData.UserId].ChannelId == LocalState.VoiceState.ChannelId)
         {
             AudioManager.PlaySoundEffect("userleave");
         }
         if (LocalState.VoiceDict.ContainsKey(e.EventData.UserId))
         {
             LocalState.VoiceDict[e.EventData.UserId] = e.EventData;
         }
         else
         {
             LocalState.VoiceDict.Add(e.EventData.UserId, e.EventData);
         }
     }
     catch
     {
         //Huh, Weird
     }
 }
Example #3
0
 private static void Gateway_GuildUpdated(object sender, GatewayEventArgs <Guild> e)
 {
     if (LocalState.Guilds.ContainsKey(e.EventData.Id))
     {
         App.GuildUpdated(e.EventData);
     }
 }
Example #4
0
 private static void Gateway_SessionReplaced(object sender, GatewayEventArgs <SessionReplace> e)
 {
     if (e.EventData != null)
     {
         session = e.EventData.SessionId;
     }
 }
 private void Gateway_RelationshipRemoved(object sender, GatewayEventArgs <Friend> e)
 {
     if (e.EventData.Id == profile.user.Id)
     {
         SwitchFriendValues(0);
     }
 }
Example #6
0
        /// <summary>
        /// Remove user from Panel
        /// </summary>
        private async Task RemoveRelationshipFromUI(GatewayEventArgs <Friend> e)
        {
            // Run on UI thread
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                      () =>
            {
                // Item from All View
                var insideAllView = AllView.Items.FirstOrDefault(x => (x as SimpleFriend).User.Id == e.EventData.Id);
                if (insideAllView != null)
                {
                    AllView.Items.Remove(insideAllView);
                }

                // Remove from Pending View
                var insidePendingView = PendingView.Items.FirstOrDefault(x => (x as SimpleFriend).User.Id == e.EventData.Id);
                if (insidePendingView != null)
                {
                    PendingView.Items.Remove(insidePendingView);
                    App.FriendNotifications -= 1;
                    PendingCounter.Text      = App.FriendNotifications.ToString();
                }

                // Remove from Blocked View
                var insideBlockedView = BlockedView.Items.FirstOrDefault(x => (x as SimpleFriend).User.Id == e.EventData.Id);
                if (insideBlockedView != null)
                {
                    BlockedView.Items.Remove(insideBlockedView);
                }
            });
        }
Example #7
0
 private void Gateway_GuildMemberChunk(object sender, GatewayEventArgs <GuildMemberChunk> e)
 {
     foreach (var member in e.EventData.Members)
     {
         SearchResults.Items.Add(member.User.Username);
     }
 }
Example #8
0
        /// <summary>
        /// Add relation ship to Panel
        /// </summary>
        private async Task AddRelationshipToUI(GatewayEventArgs <Friend> e)
        {
            // Run on UI thread
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                      async() =>
            {
                // Create SimpleFriend Object
                SimpleFriend sfriend = await NewSF(e.EventData);

                // Add to appropiate list(s)
                if (sfriend.RelationshipStatus == 1)
                {
                    AllView.Items.Add(sfriend);
                }
                else if (sfriend.RelationshipStatus == 2)
                {
                    BlockedView.Items.Add(sfriend);
                }
                else if (sfriend.RelationshipStatus == 3 || sfriend.RelationshipStatus == 4)
                {
                    if (sfriend.RelationshipStatus == 3)
                    {
                        FriendNotification(sfriend.User);
                    }
                    App.FriendNotifications += 1;
                    App.UpdateUnreadIndicators();
                    PendingCounter.Text = App.FriendNotifications.ToString();
                    PendingView.Items.Add(sfriend);
                }
            });
        }
Example #9
0
 private static void Gateway_RelationShipUpdated(object sender, GatewayEventArgs <Friend> e)
 {
     if (LocalState.Friends.ContainsKey(e.EventData.Id))
     {
         LocalState.Friends[e.EventData.Id] = e.EventData;
     }
 }
Example #10
0
 /// <summary>
 /// Voice State changed
 /// </summary>
 private async void Gateway_VoiceStateUpdated(object sender, GatewayEventArgs <VoiceState> e)
 {
     // Run on UI thread
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                               () =>
     {
         if (e.EventData.ChannelId == Id)
         {
             // Add updated voice user to this list
             if (!VoiceMembers.ContainsKey(e.EventData.UserId))
             {
                 VoiceMembers.Add(e.EventData.UserId, new VoiceMemberContainer()
                 {
                     VoiceState = e.EventData
                 });
                 MemberList.Items.Add(VoiceMembers[e.EventData.UserId]);
                 if (VoiceMembers.Count > 0)
                 {
                     MemberList.Visibility = Visibility.Visible;
                 }
             }
         }
         else if (VoiceMembers.ContainsKey(e.EventData.UserId))
         {
             // Remove updated voice user from this list
             MemberList.Items.Remove(VoiceMembers[e.EventData.UserId]);
             VoiceMembers.Remove(e.EventData.UserId);
             if (VoiceMembers.Count == 0)
             {
                 MemberList.Visibility = Visibility.Collapsed;
             }
         }
     });
 }
Example #11
0
 private static void Gateway_GuildDeleted(object sender, GatewayEventArgs <GuildDelete> e)
 {
     //TODO: Deal with guild outages
     if (LocalState.Guilds.ContainsKey(e.EventData.GuildId))
     {
         App.GuildDeleted(e.EventData.GuildId);
     }
 }
Example #12
0
 /// <summary>
 /// Add RelationShip when added
 /// </summary>
 private async void Gateway_RelationShipAdded(object sender, GatewayEventArgs <Friend> e)
 {
     if (e.EventData.Type == 1)
     {
         await RemoveRelationshipFromUI(e);
     }
     await AddRelationshipToUI(e);
 }
Example #13
0
        private static void Gateway_GuildChannelCreated(object sender, GatewayEventArgs <GuildChannel> e)
        {
            LocalState.Guilds[e.EventData.GuildId].channels.TryAdd(e.EventData.Id, new LocalModels.GuildChannel(e.EventData));

            if (e.EventData.GuildId == App.CurrentGuildId)
            {
                App.GuildChannelCreated(e.EventData);
            }
        }
Example #14
0
        private static void Gateway_UserSettingsUpdated(object sender, GatewayEventArgs <UserSettings> e)
        {
            var temp = LocalState.CurrentUserPresence;

            temp.Status = e.EventData.Status;
            LocalState.PresenceDict[LocalState.CurrentUser.Id] = temp;
            App.UserStatusChanged(e.EventData);
            LocalState.Settings = e.EventData;
        }
Example #15
0
 private static void Gateway_GuildChannelDeleted(object sender, GatewayEventArgs <GuildChannel> e)
 {
     LocalModels.GuildChannel channel;
     LocalState.Guilds[e.EventData.GuildId].channels.TryRemove(e.EventData.Id, out channel);
     channel = null;
     if (e.EventData.GuildId == App.CurrentGuildId)
     {
         App.GuildChannelDeleted(e.EventData.GuildId, e.EventData.Id);
     }
 }
Example #16
0
 private static void Gateway_GuildMemberUpdated(object sender, GatewayEventArgs <GuildMemberUpdate> e)
 {
     if (LocalState.Guilds[e.EventData.guildId].members.ContainsKey(e.EventData.User.Id))
     {
         var member = LocalState.Guilds[e.EventData.guildId].members[e.EventData.User.Id];
         member.Nick  = e.EventData.Nick;
         member.Roles = e.EventData.Roles;
         LocalState.Guilds[e.EventData.guildId].members[e.EventData.User.Id] = member;
     }
 }
Example #17
0
 private async void GuildUpdated(object sender, GatewayEventArgs <Guild> e)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                               () =>
     {
         if (guildId == e.EventData.Id)
         {
             GuildName.Text = e.EventData.Name;
         }
     });
 }
Example #18
0
 private static void Gateway_MessageUpdated(object sender, GatewayEventArgs <Message> e)
 {
     App.MessageEdited(e.EventData);
     if (App.CurrentChannelId == e.EventData.ChannelId)
     {
     }
     else
     {
         //TODO: Notifications (I'm actually really happy with this idea)
     }
 }
Example #19
0
        private void Gateway_UserGuildSettingsUpdated(object sender, GatewayEventArgs <GuildSetting> e)
        {
            _guildsService.AddOrUpdateGuildSettings(e.EventData.GuildId ?? "DM", e.EventData);

            foreach (var channel in e.EventData.ChannelOverrides)
            {
                _channelsService.AddOrUpdateChannelSettings(channel.ChannelId, channel);
            }

            Messenger.Default.Send(new GatewayUserGuildSettingsUpdatedMessage(e.EventData));
        }
Example #20
0
        private void Gateway_MessageCreated(object sender, GatewayEventArgs <Message> e)
        {
            var currentUser = _currentUserService.CurrentUser.Model;

            if (e.EventData.User == null)
            {
                e.EventData.User = currentUser;
            }

            Messenger.Default.Send(new GatewayMessageRecievedMessage(e.EventData));
        }
Example #21
0
 private async void Gateway_UserNoteUpdated(object sender, GatewayEventArgs <Gateway.DownstreamEvents.UserNote> e)
 {
     if (e.EventData.UserId == profile.user.Id)
     {
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                   () =>
         {
             NoteBox.Text = e.EventData.Note;
         });
     }
 }
Example #22
0
 private async void Gateway_RelationshipAdded(object sender, GatewayEventArgs <Friend> gatewayEventArgs)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                               () =>
     {
         if (gatewayEventArgs.EventData.user.Id == profile.user.Id)
         {
             SwitchFriendValues(gatewayEventArgs.EventData.Type);
         }
     });
 }
Example #23
0
 private static void Gateway_MessageDeleted(object sender, GatewayEventArgs <MessageDelete> e)
 {
     App.MessageDeleted(e.EventData.MessageId, e.EventData.ChannelId);
     if (App.CurrentChannelId == e.EventData.ChannelId)
     {
     }
     else
     {
         //TODO: Notifications (maybe)
     }
 }
Example #24
0
        private static void Gateway_DirectMessageChannelCreated(object sender, GatewayEventArgs <DirectMessageChannel> e)
        {
            if (!LocalState.DMs.ContainsKey(e.EventData.Id))
            {
                LocalState.DMs.Add(e.EventData.Id, e.EventData);
            }

            if (App.CurrentGuildIsDM)
            {
                App.DMCreated(e.EventData);
            }
        }
Example #25
0
        private static void Gateway_DirectMessageChannelDeleted(object sender, GatewayEventArgs <DirectMessageChannel> e)
        {
            if (LocalState.DMs.ContainsKey(e.EventData.Id))
            {
                LocalState.DMs.Remove(e.EventData.Id);
            }

            if (App.CurrentGuildIsDM)
            {
                App.DMDeleted(e.EventData.Id);
            }
        }
Example #26
0
        private static void Gateway_GuildChannelUpdated(object sender, GatewayEventArgs <GuildChannel> e)
        {
            if (LocalState.Guilds[e.EventData.GuildId].channels.ContainsKey(e.EventData.Id))
            {
                LocalState.Guilds[e.EventData.GuildId].channels[e.EventData.Id] = new LocalModels.GuildChannel(e.EventData);
            }

            if (e.EventData.GuildId == App.CurrentGuildId)
            {
                App.GuildChannelUpdated(e.EventData);
            }
        }
Example #27
0
 private static void Gateway_PresenceUpdated(object sender, GatewayEventArgs <Presence> e)
 {
     if (LocalState.PresenceDict.ContainsKey(e.EventData.User.Id))
     {
         LocalState.PresenceDict[e.EventData.User.Id] = e.EventData;
     }
     else
     {
         LocalState.PresenceDict.Add(e.EventData.User.Id, e.EventData);
     }
     App.PresenceUpdated(e.EventData.User.Id, e.EventData);
 }
 private async void Gateway_GuildDeleted(object sender, GatewayEventArgs <GuildDelete> e)
 {
     // If the guild is this guild
     if (DisplayedInvite?.Guild != null && e.EventData.GuildId == DisplayedInvite.Guild.Id)
     {
         // Run on UI thread
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             // Display the invite
             LoadInvite(false);
         });
     }
 }
 private async void Gateway_GuildCreated(object sender, GatewayEventArgs <Guild> e)
 {
     // If the guild is this guild
     if (DisplayedInvite?.Guild != null && e.EventData.Id == DisplayedInvite.Guild.Id)
     {
         // Run on UI thread
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             // Update the info to say it's already joined
             LoadInvite(false);
         });
     }
 }
Example #30
0
 private static void Gateway_RelationShipAdded(object sender, GatewayEventArgs <Friend> e)
 {
     if (!LocalState.Friends.ContainsKey(e.EventData.Id))
     {
         LocalState.Friends.Add(e.EventData.Id, e.EventData);
     }
     else
     {
         LocalState.Friends[e.EventData.Id] = e.EventData;
     }
     if (e.EventData.Type == 3)
     {
         Storage.UpdateNotificationState("r" + e.EventData.user.Id, e.EventData.Id);
     }
 }