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