{:uriI"Èfile:///Users/matthewchang/work/call9/push_routes/vendor/assets/javascripts/push_routes_socket_io.js.erb?type=application/javascript&id=e04774e3d0e8d76acb94f43591eab18c5b9da8cbca6679268a4de0c05e7f1339:ET:load_pathI"I/Users/matthewchang/work/call9/push_routes/vendor/assets/javascripts;T: filenameI"f/Users/matthewchang/work/call9/push_routes/vendor/assets/javascripts/push_routes_socket_io.js.erb;T: nameI"push_routes_socket_io;T:logical_pathI"push_routes_socket_io.js;T:content_typeI"application/javascript;T: sourceI" //TODO: configurable accross the application var NODE_URL = "http://localhost:5000"; var PushRoutes = { socket: null, connect: function(params) { var self = this; server = params.server || NODE_URL; user_id = params.id || ""; authentication_token = params.authentication_token || ""; self.socket = io.connect(server, {secure: true}); self.socket.on('connect', function() { self.socket.connected = true; console.log("Connecting Socket"); self.socket.removeAllListeners('disconnect'); self.socket.removeAllListeners('unauthorized'); self.socket.removeAllListeners('authenticated'); self.socket.on('disconnect',function() { self.socket.connected = false; console.log('Socket Disconnected'); }); self.socket.on('unauthorized', function(err){ console.log("Authentication was rejected:", err.message); }); self.socket.on('authenticated', function() { console.log("Authentication successful"); for(var route in self.subscriptions) { self.register_subscription(route,self.subscriptions[route]); } if(params.callback) { params.callback(); } }); self.socket.emit("authentication",{user_id: user_id, authentication_token: authentication_token}, function(error,message) { console.log(error); console.log(message); }); }) }, subscriptions: {}, subscribe: function(route,on_update) { this.subscriptions[route] = on_update; this.register_subscription(route,on_update); }, register_subscription: function(route,on_update) { if(this.socket && this.socket.connected) { this.socket.removeAllListeners(route); this.socket.on(route,function(message) { on_update(message); }); this.socket.emit("subscribe",route,function() { console.log("Subscribed to "+route); }); } else { console.log("Socket not connected"); } }, unsubscribe: function(route) { delete this.subscriptions[route]; this.socket.removeAllListeners(route); }, setDebugString: function(string) { this.socket.emit("set_debug_string",string); } } ;T: metadata{ :dependencieso:Set: @hash} I"environment-version;TTI"environment-paths;TTI"rails-env;TTI"Yprocessors:type=application/javascript&file_type=application/javascript&engines=.erb;TTI"tfile-digest:///Users/matthewchang/work/call9/push_routes/vendor/assets/javascripts/push_routes_socket_io.js.erb;TTI"gprocessors:type=application/javascript&file_type=application/javascript&engines=.erb&pipeline=self;TTF: linkso;;}F: included[I"Öfile:///Users/matthewchang/work/call9/push_routes/vendor/assets/javascripts/push_routes_socket_io.js.erb?type=application/javascript&pipeline=self&id=8f0af8329fd4b54c8de1122bb924ae615cbf90fb5899eddf25042bb4b775e766;T: charsetI" utf-8;F: digest"%Y¦uÈcÁŸ-°ß-ØcP3¥÷ïÆ à<÷íCWtŠ: lengthi :dependencies_digest"%Ú3Žý·5[=þa+º”à6_6mwçøO*úm>ðb]:idI"Ee04774e3d0e8d76acb94f43591eab18c5b9da8cbca6679268a4de0c05e7f1339;F: mtimel+CCW