public Notification Create(string uniqueID, string text, Hashtable data, NotficationRespondAction respondAction, NotificationSourceServiceType serviceType, NotificationSubType subType) { Notification notification = new Notification { uniqueID = uniqueID, data = data, handled = false, id = Guid.NewGuid().ToString(), respondAction = (int)respondAction, sourceServiceType = (int)serviceType, text = text, subType = (int)subType }; return(notification); }
/// <summary> /// Handle notfication for player request /// </summary> /// <param name="characterId">Character id</param> /// <param name="notificationId">Notification id</param> /// <param name="response">true - player tap YES(true allowed only on YesDelete notifications), false - player tap delete</param> public void HandleNotification(string characterId, string notificationId, bool response) { var notifications = GetNotifications(characterId); if (notifications == null) { log.InfoFormat("notifications for character = {0} not founded", characterId); return; } var notification = notifications.Get(notificationId); if (notification == null) { log.InfoFormat("notification = {0} for character = {1} not founded", notificationId, characterId); return; } if (response) { NotficationRespondAction action = (NotficationRespondAction)notification.respondAction; if (action != NotficationRespondAction.YesDelete) { log.InfoFormat("notification = {0} for character = {1} don't have required action type YesDelete", notificationId, characterId); return; } else { NotificationSourceServiceType serviceType = (NotificationSourceServiceType)notification.sourceServiceType; if (serviceType == NotificationSourceServiceType.Guild) { //handle notification for guild mApplication.Guilds.HandleNotification(characterId, notification); } else if (serviceType == NotificationSourceServiceType.Friends) { mApplication.friends.HandleNotification(notification); } else if (serviceType == NotificationSourceServiceType.Server) { log.InfoFormat("handle Server notification {0}", notificationId); } else if (serviceType == NotificationSourceServiceType.Group) { SelectCharacterClientPeer peer; if (mApplication.Clients.TryGetPeerForCharacterId(characterId, out peer)) { DbPlayerCharactersObject player; if (mApplication.Players.TryGetPlayer(peer.id, out player)) { mApplication.Groups.HandleNotification(peer.id, characterId, player.Login.ToLower(), notification.data as Hashtable); } else { log.Info("player not found"); } } else { log.Info("peer not found"); } } notification.handled = true; mCache.SetChanged(characterId, true); } } else { notifications.Remove(notificationId); mCache.SetChanged(characterId, true); } }