diff options
author | Kyle Gunger <corechg@gmail.com> | 2020-04-03 16:44:23 -0400 |
---|---|---|
committer | Kyle Gunger <corechg@gmail.com> | 2020-04-03 16:44:23 -0400 |
commit | 1697da112a9b9f529fad2f54c62aecd7bbb614e6 (patch) | |
tree | 68c7cd383107e824953b6aa213d05d9a6842b73f /webcards/scripts/client/sock.js | |
parent | 3040a822085adeb9025ddc1a4573cf37cb37d377 (diff) |
[WEBCARDS] Update some webcards stuff
Diffstat (limited to 'webcards/scripts/client/sock.js')
-rw-r--r-- | webcards/scripts/client/sock.js | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/webcards/scripts/client/sock.js b/webcards/scripts/client/sock.js deleted file mode 100644 index 78c4195..0000000 --- a/webcards/scripts/client/sock.js +++ /dev/null @@ -1,52 +0,0 @@ -function SockWorker(serveraddr, version, callback) { - this.server = serveraddr; - this.version = version; - this.cb = callback; -} - -SockWorker.prototype = { - init: function() { - if(this.server == "" || this.server == null) { - return; - } - try { - this.socket = new WebSocket(this.server); - - this.socket.addEventListener("open", this.o.bind(this)); - this.socket.addEventListener("message", this.msg.bind(this)); - - this.socket.addEventListener("closed", this.c.bind(this)); - this.socket.addEventListener("error", this.err.bind(this)); - } catch (e) { - this.err(); - } - }, - - o: function() { - this.send("version", this.version); - }, - - msg: function(e) { - if(typeof e.data == "string") { - var dat = JSON.parse(e.data) - this.cb(dat); - } - }, - - c: function() { - this.cb({type: "close", data: ""}); - }, - - err: function() { - this.cb({type: "error", data: ""}); - }, - - close: function() { - this.socket.close(); - }, - - send: function(type, data) { - var m = new Message(type, data); - this.socket.send(m.stringify()) - } -};
\ No newline at end of file |