summaryrefslogtreecommitdiff
path: root/public/js/lib/ws.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/lib/ws.js')
-rw-r--r--public/js/lib/ws.js38
1 files changed, 21 insertions, 17 deletions
diff --git a/public/js/lib/ws.js b/public/js/lib/ws.js
index 4326585..3d62ef0 100644
--- a/public/js/lib/ws.js
+++ b/public/js/lib/ws.js
@@ -1,29 +1,31 @@
-var ws = function(){
+var ws = (function(){
var ws = {}
- var ready = false
- var socket
- ws.connect = function () {
- if (socket) return;
- var path_name = window.location.pathname.replace(/\/$/,"").split("/")
- var path = window.location.origin + '/' + path_name[path_name.length-1]
+ var socket, ready
+ ws.connect = function (room) {
+ if (this.socket) return;
- ws.socket = io(path)
- ws.socket.on('ready', ws.ready)
- ws.socket.on('error', ws.error)
- ws.socket.on('connect', ws.connected)
- ws.socket.on('reconnect', ws.reconnected)
- ws.socket.on('disconnect', ws.disconnected)
+ var path = window.location.origin + '/' + room
+
+ ws.socket = socket = io(path)
+ // this.socket.on('connect', function(){ console.log(new Date(), "connected")})
+ socket.on('ready', ws.ready)
+ socket.on('error', ws.error)
+ socket.on('connect', ws.connected)
+ socket.on('reconnect', ws.reconnected)
+ socket.on('disconnect', ws.disconnected)
+ return socket
}
-
- ws.ready = function (data) {
+
+ ws.ready = function (obj) {
console.log(new Date(), "ready")
// presumably we might have reconnected?
if (ready) {
+ // this.chatView.fetchAndDedupe()
}
else {
ready = true
- ws.checkIfLoaded()
+ // this.checkIfLoaded()
}
}
@@ -38,5 +40,7 @@ var ws = function(){
}
ws.disconnected = function (){
console.log(new Date(), "disconnected")
+ // this.chatView.appendInfo({ content: "Disconnected." })
}
-} \ No newline at end of file
+ return ws
+})()