summaryrefslogtreecommitdiff
path: root/scripts/socket/message.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/socket/message.js')
-rw-r--r--scripts/socket/message.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/socket/message.js b/scripts/socket/message.js
new file mode 100644
index 0000000..044027d
--- /dev/null
+++ b/scripts/socket/message.js
@@ -0,0 +1,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});
+ }
+}