public void avatarrequestedmefriends(string username, string token) { var a = GetAvatar(username, token); if (a != null) { var friends = AFriendManager.Instance.OnGetRequestedMeFriends(a.AvatarName); SendError("requests", AFriendManager.ToJson(a.AvatarName, friends)); } }
public void avatarmyfriendlist(string username, string token) { var a = GetAvatar(username, token); if (a != null) { var friends = AFriendManager.Instance.OnGetFriends(a.AvatarName); SendError("friends", AFriendManager.ToJson(a.AvatarName, friends.Values.ToList())); } }
public void avataraddfriend(string username, string token, string friendname) { var a = GetAvatar(username, token); if (a != null) { if (a.AvatarName == friendname) { SendError(ErrorDefs.CannotAddYourSelf); return; } var myfriends = AFriendManager.Instance.OnGetFriends(a.AvatarName); if (myfriends.Count >= InitValueDefs.MaxFriends) { SendError(ErrorDefs.TooManyFriends); return; } var targetfriends = AFriendManager.Instance.OnGetFriends(friendname); if (targetfriends.Count >= InitValueDefs.MaxFriends) { SendError(ErrorDefs.TargetTooManyFriends); return; } var friend = dbavatar.FindOneData(TableName , ADBAccessor.filter_eq(InfoNameDefs.AvatarName, friendname) , ADBAccessor.projections(InfoNameDefs.AvatarName)); if (friend == null) { SendError(ErrorDefs.NoSuchUser); return; } var added = AFriendManager.Instance.OnAddFriend(a.AvatarName, friendname); if (added == 0) { var friends = AFriendManager.Instance.OnGetFriends(a.AvatarName); SendError("friends", AFriendManager.ToJson(a.AvatarName, friends.Values.ToList())); } else if (added == -1) { SendError(ErrorDefs.WaitingForResponse); } else if (added == 1) { SendError(ErrorDefs.AlreadyFriends); } } }
public void avatarrefusefriend(string username, string token, string friendname) { var a = GetAvatar(username, token); if (a != null) { if (AFriendManager.Instance.OnRefuseFriend(a.AvatarName, friendname)) { var friends = AFriendManager.Instance.OnGetRequestedMeFriends(a.AvatarName); SendError("requests", AFriendManager.ToJson(a.AvatarName, friends)); } else { SendError(ErrorDefs.TargetNoRequested); } } }
public void avatardeletefriend(string username, string token, string friendname) { var a = GetAvatar(username, token); if (a != null) { var friends = AFriendManager.Instance.OnGetFriends(a.AvatarName); if (!friends.ContainsKey(friendname)) { SendError(ErrorDefs.TargetIsNotYourFriend); return; } AFriendManager.Instance.OnDeleteFriend(a.AvatarName, friendname); friends = AFriendManager.Instance.OnGetFriends(a.AvatarName); SendError("friends", AFriendManager.ToJson(a.AvatarName, friends.Values.ToList())); } }