public void GetInfo(long uid = 0) { bool isReqHistory = false; //if (!Info.IsHaveReqHistory) //{ // Info.IsHaveReqHistory = true; // isReqHistory = true; //} long lastTime = Instance.Info.LastMessageTs + 2; Api.GetInfo(uid, lastTime, isReqHistory, delegate(EB.Sparx.Response response) { if (response != null && response.hashtable != null) { DataLookupsCache.Instance.CacheData(response.hashtable); ArrayList history = Hotfix_LT.EBCore.Dot.Array("friendsInfo.history", response.hashtable, null); if (isReqHistory && history == null) { EB.Debug.LogError("isReqHistory && history array == null"); } if (isReqHistory && history != null) { for (int i = 0; i < history.Count; ++i) { var msg = EB.Sparx.ChatMessage.Parse(history[i]); if (msg.ts <= lastTime) { EB.Debug.LogError("newest offline msg ts<=lasttime lasttime={0},msg.ts={1}", lastTime, msg.ts); continue; } Instance.Info.LastMessageTs = msg.ts; Info.AddUnreadMessageId(LTChatManager.Instance.GetTargetId(msg.uid, msg.privateUid)); ChatHistory.SaveData(msg); } } response.hashtable.Remove("history"); FetchDataHandler(response); } }); }
private void OnHandleAsyncMessage(EB.Sparx.ChatMessage[] msgs) { ChatRule.CHAT_CHANNEL channelType = ChatRule.CHAT_CHANNEL.CHAT_CHANNEL_PRIVATE; string privateChannel = ChatRule.CHANNEL2STR[channelType]; for (int i = 0, len = msgs.Length; i < len; ++i) { var msg = msgs[i]; if (msg.channelType == privateChannel) { Info.LastMessageTs = msg.ts; Info.NewestSendId = LTChatManager.Instance.GetTargetId(msg.uid, msg.privateUid); ChatHistory.SaveData(msg); if (msg.privateUid == LoginManager.Instance.LocalUserId.Value) { Info.AddUnreadMessageId(Info.NewestSendId); } Messenger.Raise(Hotfix_LT.EventName.FriendMessageEvent, msg.uid); } } }