summaryrefslogtreecommitdiff
path: root/scripts/socket/message.js
blob: 0288cbc2c61bf7952e9b82477f8b193e21ba8f47 (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});
	}
}