using UnityEngine; using System.Collections; using Newtonsoft.Json.Linq; using System.Collections.Generic; using System; using System.Linq; using System.Text; /// /// 好友模块 /// [Obsolete("尚未修缮, --gwang")] public class FriendProxy : ProxyBase { #region ` 构造函数 ` /// /// init /// public FriendProxy() => this.opeCode = OpeCode.ope_friend; #endregion #region ` 本地字段 ` /// /// 当天的发出邀请加好友的记录 /// Dictionary mApplied = new Dictionary(); /// /// 查询其他人的 共享的英雄信息记录 /// public Dictionary mQueryStrengtherSharedHeroDic = new Dictionary(); /// /// 记录个人的发送礼物记录 /// public Dictionary mSendGiftToMyFriendRecord = new Dictionary(); #endregion /// /// 6101 [好友-请求加好友1] /// 向陌生人发送好友申请 /// /// 想加的好友UID /// 成功回调(无返回参数) public void SendInvitationToStranger(string targetUID, Action callback) { Post(CmdCode.friend_SendInvitationToStranger, new object[] { targetUID }, resp => { if (!mApplied.ContainsKey(targetUID)) { mApplied.Add(targetUID, DateTime.Now.tsDay().ToString()); } callback?.Invoke(resp.result); }); } /// /// [6102][好友-同意好友请求] /// /// 想加的好友UID /// 成功回调处理 public void AgreeToFriends(List targetUIDList, Action callback) { Post(CmdCode.friend_AgreeToFriends, new object[] { string.Join(",", targetUIDList.ToArray()) }, resp => callback?.Invoke(resp.result)); } /// /// 6103 [好友-拒绝好友请求] /// /// 拒绝好友UID /// 成功回调处理 public void RefusedStranger(string targetUID, Action callback) { Post(CmdCode.friend_RefusedStranger, new object[] { targetUID }, resp => callback?.Invoke(resp.result)); } /// /// [6104][好友-删除好友] /// /// 删除好友UID /// 成功回调处理 public void DeleteFriends(string targetUID, Action callback) { Post(CmdCode.friend_DeleteFriends, new object[] { targetUID }, resp => callback?.Invoke(resp.result)); } /// /// [6105 ]好友---请求别人给我发来的好友邀请信息 /// /// 成功回调处理 public void QueryOthersInviteMeMessage(Action callback) { Post(CmdCode.friend_QueryOthersInviteMeMessage, new object[] { }, resp => callback?.Invoke(resp.result)); } /// /// [6106 ][好友-拉取我的好友列表] /// /// 成功回调处理 public void QueryMyFriends(Action callback) { Post(CmdCode.friend_QueryMyFriends, new object[] { }, resp => callback?.Invoke(resp.result)); } /// /// [6107 ][好友-拉取好友的共享英雄详细信息] /// /// 目标英雄ID /// 成功回调处理 public void QueryFriendSharedHeroInfo(List targetUIDList, Action callback) { Post(CmdCode.friend_QueryFriendSharedHeroInfo, new object[] { string.Join(",", targetUIDList.ToArray()) }, resp => { if (resp.result["ret"] != null && resp.result["ret"].HasValues) { JObject friendList = resp.result["ret"] as JObject; if (friendList.HasValues) { foreach (JProperty st in friendList.Children()) { if (!mQueryStrengtherSharedHeroDic.ContainsKey(st.Name)) { mQueryStrengtherSharedHeroDic.Add(st.Name, st.Value as JObject); } else { mQueryStrengtherSharedHeroDic[st.Name] = st.Value as JObject; } } } } callback?.Invoke(resp.result); }); } /// /// [6108] [好友-发送好友留言] /// /// 目标英雄 /// 留言 /// 成功回调处理 public void SendMessageToFriends(string targetUID, string msg, int ts, Action callback) { Post(CmdCode.friend_SendMessageToFriends, new object[] { targetUID, msg, ts }, resp => callback?.Invoke(resp.result)); } /// /// [6109] [好友-刷新好友留言消息] /// /// 操作的英雄UID /// 最后一条消息的ts /// 成功回调处理 public void RefreshFriendLeaveMessage(string heroUId, int ts, Action callback) { Post(CmdCode.friend_RefreshFriendLeaveMessage, new object[] { heroUId, ts }, resp => callback?.Invoke(resp.result)); } /// /// [6110] [好友-搜索好友] /// /// 搜索关键字 /// 分页 /// 成功回调处理 public void SearchStranger(string filter, int pageId, Action callback) { Post(CmdCode.friend_SearchStranger, new object[] { filter, pageId }, resp => { if (resp.result["applied"] != null && resp.result["applied"].HasValues) { mApplied = (resp.result["applied"] as JObject).ToObject>(); } callback?.Invoke(resp.result); }); } /// /// [6111] [好友 -- 添加好友 :::系统推荐的 陌生人列表] /// /// 分页 /// 成功回调处理 public void SystemProvideStrangerList(int pageId, Action callback) { Post(CmdCode.friend_SystemProvideStrangerList, new object[] { pageId }, resp => { if (resp.result["applied"] != null && resp.result["applied"].HasValues) { mApplied = (resp.result["applied"] as JObject).ToObject>(); } callback?.Invoke(resp.result); }); } /// /// [6113] [好友 -- 拉取 别人给我发送礼物的信息] /// ;参数: 无 ///;返回值: "ret":{"gwang":[22334,12345],...} /// /// 分页 /// 成功回调处理 public void QueryOtherFriendSendMeGiftMessages(Action callback) { Post(CmdCode.friend_QueryOtherFriendSendMeGift, new object[] { }, resp => callback?.Invoke(resp.result.ToObject())); } /// /// [6114] [好友 -- 收取别人给我发送的礼物 并回赠] /// [好友-收取好友赠送礼物_并回赠] ///;参数: 逗号分割的uid和tsday组合(好友记录的uid和ts拼到一起), 是否回赠 ///req={"uid":"wanggangzero.cn","ope":601,"cmd":6114,"paras":["gwang12346"],"sig":"w","msgid":"w","ts":0,"zoneid":1,"clientVer":"1.0.1","tag":null} /// /// 分页 /// 成功回调处理 [Obsolete("-",true)] public void ReceiveAndSendGiftToFriend(List targetUIDList, Action callback) { Post(CmdCode.friend_ReceiveAndSendGiftToFriend, new object[] { string.Join(",", targetUIDList.ToArray()) }, resp => { // UserProxy.Instance.player.ChangeFriendPoint(resp.result["ret"].ToObject()); callback?.Invoke(resp.result); }); } /// /// [6115] [好友 -- 给我的好友赠送礼物 ] /// /// 分页 /// 成功回调处理 public void SendGiftToMyFriends(List targetUIDList, Action callback) { Post(CmdCode.friend_SendGiftToMyFriends, new object[] { string.Join(",", targetUIDList.ToArray()) }, resp => callback?.Invoke(resp.result)); } /// /// [6116] 检查玩家的好友信息是否有未处理的 /// /// /// public void CheckUnduckMessage(Action callback) { Post(CmdCode.friend_unduckmsg, new object[] { }, resp => callback?.Invoke(resp.result)); } /// /// [6117] 检查玩家的好友信息是否有未处理的 /// /// /// public void LookGuildInfo(string friendId, Action callback) { Post(CmdCode.cmd_user_friend_LookGuildInfo, new object[] { friendId }, resp => callback?.Invoke(resp.result)); } #region ` 辅助方法 ` /// /// 查询好友共享英雄信息 /// /// /// public JObject FindRecordFriendSharedHeroInfo(string uid) { if (mQueryStrengtherSharedHeroDic.ContainsKey(uid)) { return mQueryStrengtherSharedHeroDic[uid]; } return null; } /// /// 检查今天是否给某个人发送了好友申请 /// true = 已申请 /// false = 未申请 /// /// /// internal bool CheckHasInviteSomeOne(string mStrengtherUID) => mApplied.ContainsKey(mStrengtherUID); /// /// 检查 我今天是否给某个好友发送礼物了 /// true = 已发送 /// false = 未发送 /// /// /// internal bool CheckTodayHasSendGift(string mStrengtherUID) { if (mSendGiftToMyFriendRecord.ContainsKey(mStrengtherUID)) { if (mSendGiftToMyFriendRecord[mStrengtherUID] == DateTime.Now.tsDay()) { return true; } } return false; } #endregion }