void SaveChatLogInfo() { if (m_ChatLogList.Count == 0) { return; } System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms); bw.Write(m_ChatLogList.Count); for (int i = 0; i < m_ChatLogList.Count; ++i) { bw.Write(m_ChatLogList[i].m_IsMySelf); bw.Write(m_ChatLogList[i].m_UserID); bw.Write(m_ChatLogList[i].m_DataTime); bw.Write(m_ChatLogList[i].m_ChatStr); } RuntimeInfo.SaveLocalChatFile(RuntimeInfo.GetChatLogFileName(PlayerRole.Instance.RoleInfo.RoleMe.GetUserID(), m_UserID), ms.ToArray()); bw.Close(); }
public void DeleteFriend(uint userID) { for (byte i = 0; i < m_FriendList.Count;) { if (m_FriendList[i].FriendItemInfo.GetUserID() == userID) { FriendItemUI item = m_FriendList[i]; m_Grid[0].RemoveChild(item.m_BaseTrans); item.ShutDown(); Utility.ListRemoveAt(m_FriendList, i); //删除完好友后将本地保聊天信息清除 RuntimeInfo.DeleteLocalChatFile(RuntimeInfo.GetChatLogFileName(PlayerRole.Instance.RoleInfo.RoleMe.GetUserID(), userID)); break; } else { i++; } } m_ScrollTrans[0].localPosition = new Vector3(151, 46.8f, 0); m_UIPanel[0].clipOffset = new Vector2(0, -142); m_FriendsCout.text = string.Format("当前好友数:{0}", m_FriendList.Count); }
void LoadChatLogInfo() { byte[] data = RuntimeInfo.GetLocalChatFile(RuntimeInfo.GetChatLogFileName(PlayerRole.Instance.RoleInfo.RoleMe.GetUserID(), m_UserID)); if (data == null) { return; } System.IO.MemoryStream ms = new System.IO.MemoryStream(data); System.IO.BinaryReader br = new System.IO.BinaryReader(ms); uint logNum = br.ReadUInt32(); for (int i = 0; i < logNum; ++i) { ChatInfo info = new ChatInfo(); info.m_IsMySelf = br.ReadByte(); info.m_UserID = br.ReadUInt32(); info.m_DataTime = br.ReadString(); info.m_ChatStr = br.ReadString(); m_ChatLogList.Add(info); } ms.Close(); br.Close(); }