public void UpdateMessage(User user, int last_update, ref CHAT_LIST chat_list ) { // 50 개만 셀렉트하기 IEnumerable<ChatMessage> query = from chat in _instantChat where chat.Index > last_update select chat; int nCount = query.Count<ChatMessage>(); chat_list.count = nCount; chat_list.room_index = this.Index; chat_list.CHAT = new CHAT_LISTCHAT[nCount]; int nIndex = 0; foreach (ChatMessage msg in query) { chat_list.CHAT[nIndex] = new CHAT_LISTCHAT(); chat_list.CHAT[nIndex].chat_index = msg.Index; chat_list.CHAT[nIndex].date_time = msg.IptTime; chat_list.CHAT[nIndex].nick_name = msg.UserNickName; chat_list.CHAT[nIndex].Value = msg.Content; chat_list.CHAT[nIndex].login_id = msg.LoginId; if (user.UserGuid.Equals(msg.UserGuid)) { chat_list.CHAT[nIndex].ownerSpecified = true; chat_list.CHAT[nIndex].owner = 1; } else { chat_list.CHAT[nIndex].ownerSpecified = false; } nIndex++; } }
public void InsertMessage(String contents, User user, int last_update, ref CHAT_LIST chat_list) { ChatMessage msg = new ChatMessage(); msg.Content = contents; msg.Index = _instantChat.Count + 1; msg.IptTime = DateTime.Now; msg.UserNickName = user.UserName; msg.UserGuid = user.UserGuid; msg.LoginId = user.LoginId; _instantChat.Add(msg); this.UpdateMessage(user, last_update, ref chat_list); }