summaryrefslogtreecommitdiff
path: root/scripts/message.js
blob: 5e821c44ee37d7b9c65016a7961a1eb68831d20b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function Message(type, data){
    this.t = type;
    this.d = data;
}

Message.prototype = {
    stringify: function(){
        var dat = this.d
        if(typeof dat !== "string"){
            dat = JSON.stringify(dat);
        }
        return JSON.stringify({type: this.t, data: dat});
    }
};