summaryrefslogtreecommitdiff
path: root/scripts/socket/message.js
blob: 044027d7338832ff1be313770072fa1cce93d280 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'use strict';

class Message{
    constructor (type, data)
    {
        this.t = type;
        this.d = data;
    }

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