Ejemplo n.º 1
0
        public Message(NewMessageNotification message)
        {
            Id             = message.fields.args[0]._id;
            RoomId         = message.fields.args[0].rid;
            MessageContent = message.fields.args[0].msg;
            Timestamp      = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
            double seconds = double.Parse(message.fields.args[0].ts.date);

            Timestamp = Timestamp.AddMilliseconds(seconds).ToLocalTime();
            User      = new User {
                Id = message.fields.args[0].u._id, Username = message.fields.args[0].u.username
            };
            if (message.fields.args[0].file != null)
            {
                File = new MessageFile(message.fields.args[0].file);
            }
            if (message.fields.args[0].attachments != null)
            {
                Attachments = new Attachment[message.fields.args[0].attachments.Length];
                for (int i = 0; i < Attachments.Length; i++)
                {
                    Attachments[i] = new Attachment(message.fields.args[0].attachments[i]);
                }
            }
        }
Ejemplo n.º 2
0
 public Message(ChatHistoryMessage message)
 {
     Id             = message._id;
     RoomId         = message.rid;
     MessageContent = message.msg;
     Timestamp      = Convert.ToDateTime(message.ts);
     User           = new User {
         Id = message.u._id, Username = message.u.username
     };
     Groupable = message.groupable;
     UpdatedAt = Convert.ToDateTime(message._updatedAt);
     if (message.t == "uj")
     {
         UserJoined = true;
     }
     else
     {
         UserJoined = false;
     }
     if (message.file != null)
     {
         File = new MessageFile(message.file);
     }
     if (message.attachments != null)
     {
         Attachments = new Attachment[message.attachments.Length];
         for (int i = 0; i < Attachments.Length; i++)
         {
             Attachments[i] = new Attachment(message.attachments[i]);
         }
     }
 }