Beispiel #1
0
        public void AddChatMessage(ChatMessageRoomModel message)
        {
            var msgElement = jQuery.Select("<div></div>");
            msgElement.CSS("background-color", "#DDDDDD");

            msgElement.Append(jQuery.Select("<span>" + message.User.UserName + "</span>"));
            msgElement.Append(jQuery.Select("<span>&nbsp;&nbsp;:&nbsp;&nbsp;</span>"));
            msgElement.Append(jQuery.Select("<span>" + message.Content + "</span>"));

            Element.Append(msgElement);
            Element.ScrollTop(Element.GetHeight());
        }
        public void AddChatLine(UserLogicModel user, ChatRoomModel room, string message, Action<ChatMessageRoomModel> complete)
        {
            manager.client.Collection("ChatRoom",
                                      (err, collection) => {
                                          ChatMessageRoomModel messageModel = new ChatMessageRoomModel(user, message, DateTime.Now);

                                          JsDictionary<string, object> query = new JsDictionary<string, object>();

                                          query["$push"] = new {messages = messageModel};

                                          collection.Update(new { _id = MongoDocument.GetID(room.ID )},
                                                            query,
                                                            (err2) => {
                                                                if (err2 != null)
                                                                    Logger.Log("Data Error: " + err2,LogLevel.Error);
                                                                room.Messages.Add(messageModel);
                                                                complete(messageModel);
                                                            });
                                      });
        }