ensl_gathers/lib/chat/message.js

22 lines
376 B
JavaScript
Raw Normal View History

2015-07-21 14:10:24 +00:00
"use strict";
2015-07-22 13:53:50 +00:00
var Author = require("./author");
2015-07-29 14:54:45 +00:00
var count = 0;
2015-07-21 14:10:24 +00:00
function Message (o) {
2015-07-29 14:54:45 +00:00
this.id = count++;
2015-07-21 14:10:24 +00:00
this.author = Author(o.author);
this.content = o.content;
this.createdAt = new Date();
};
Message.prototype.toJson = function () {
return {
2015-07-29 14:54:45 +00:00
id: this.id,
2015-07-22 23:30:14 +00:00
author: this.author,
2015-07-21 14:10:24 +00:00
content: this.content,
createdAt: this.createdAt
}
};
module.exports = Message;