/// <summary> /// Send array all notifications to user. /// </summary> /// <param name="user">user.</param> /// <exception cref="ConnectionInterruptedException"></exception> private void SendNotifications(OnlineUser user) { Notification[] notifications = DBoperations.GetNotifications(user.Id); foreach (var notification in notifications) { if (notification.accept_friendship) { user.Client.SendMessage(new UserActionMessage { UserLogin = DBoperations.GetUserLogin(notification.user_two), Time = notification.time, Action = UserActions.AcceptFriendship }); } else if (notification.reject_friendship) { user.Client.SendMessage(new UserActionMessage { UserLogin = DBoperations.GetUserLogin(notification.user_two), Time = notification.time, Action = UserActions.RejectFriendship }); } else if (notification.send_friendship) { user.Client.SendMessage(new UserActionMessage { UserLogin = DBoperations.GetUserLogin(notification.user_two), Time = notification.time, Action = UserActions.SendFriendshipRequest }); } else if (notification.cancel_friendship) { user.Client.SendMessage(new UserActionMessage { UserLogin = DBoperations.GetUserLogin(notification.user_two), Time = notification.time, Action = UserActions.CancelFriendshipRequest }); } else if (notification.remove_friend) { user.Client.SendMessage(new UserActionMessage { UserLogin = DBoperations.GetUserLogin(notification.user_two), Time = notification.time, Action = UserActions.RemoveFromFriends }); } else { user.Client.SendMessage(new UserActionMessage { UserLogin = DBoperations.GetUserLogin(notification.user_two), Time = notification.time, Action = UserActions.MessageSended }); } } // delete notifications from db DBoperations.RemoveNotifications(user.Id); }