ChatFollow.cs 974 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class ChatFollow
  5. {
  6. public int userId;
  7. private List<ChatMsg> list;
  8. public ChatFollow()
  9. {
  10. list = new List<ChatMsg> ();
  11. }
  12. public void AddMsg(ChatMsg chatMsg)
  13. {
  14. list.Add (chatMsg);
  15. while(list.Count > ChatManager.MAX_FOLLOW)
  16. {
  17. list.RemoveAt (0);
  18. }
  19. Follower follower = null;
  20. if(chatMsg.receiver == Session.GetInstance().myUserData.id)
  21. follower = FollowManager.GetInstance().GetFollower(chatMsg.sender);
  22. else
  23. follower = FollowManager.GetInstance().GetFollower(chatMsg.receiver);
  24. if (follower == null)
  25. return;
  26. follower.AddMsg (chatMsg);
  27. }
  28. public List<ChatMsg> GetChatList()
  29. {
  30. return list;
  31. }
  32. public string GetLastMsg()
  33. {
  34. if(list.Count > 0)
  35. {
  36. return list [list.Count - 1].content;
  37. }
  38. return "";
  39. }
  40. public string GetLastMsgTime()
  41. {
  42. if(list.Count > 0)
  43. {
  44. return list [list.Count - 1].GetTimeStr();
  45. }
  46. return "";
  47. }
  48. }