public void Handle(ISession session) { ChatSession chatSession = session as ChatSession; ConversationFrIDResponse packet = new ConversationFrIDResponse(); packet.ConversationID = ConversationID.ToString(); var conversationStore = new ConversationStore().Load(ConversationID); packet.LastActive = 0; packet.ConversationName = ""; if (conversationStore == null) { packet.StatusCode = 404; } else { packet.StatusCode = 200; conversationStore.UpdateLastActive(chatSession); packet.LastActive = conversationStore.LastActive; if (conversationStore is SingleConversation) { packet.ConversationName = "~"; } else { packet.ConversationName = conversationStore.ConversationName; } foreach (var member in conversationStore.Members) { packet.Members.Add(member.ToString()); } packet.LastMessID = conversationStore.MessagesID.Count - 1; packet.LastMediaID = conversationStore.MediaID.Count - 1; packet.LastAttachmentID = conversationStore.AttachmentID.Count - 1; } packet.BubbleColor = conversationStore.Color; // Update later packet.PreviewCode = -1; packet.PreviewContent = ""; chatSession.Send(packet); }
public void Handle(ISession session) { GetConversationShortInfoResponse packet = new GetConversationShortInfoResponse(); packet.ConversationID = ConversationID.ToString(); ChatSession chatSession = session as ChatSession; AbstractConversation conversation = new ConversationStore().Load(ConversationID); int cnt = 0; packet.ConversationName = ""; if (string.IsNullOrEmpty(conversation.ConversationName) || conversation.ConversationName.Equals("~")) { foreach (var member in conversation.Members) { if (member.CompareTo(chatSession.Owner.ID) == 0) { continue; } string name = new ChatUserStore().Load(member).FirstName; packet.ConversationName += name + ", "; cnt++; if (cnt >= 2) { break; } } if (cnt >= 2) { packet.ConversationName += "and " + (conversation.Members.Count - 3) + "others..."; } else { packet.ConversationName = packet.ConversationName.Replace(", ", ""); } } conversation.UpdateLastActive(chatSession); packet.LastActive = conversation.LastActive; chatSession.Send(packet); }