Created an env var for disabling sockets
[osm/UI.git] / skyquake / framework / core / api_utils / sockets.js
index 2e6779c..e8ae2eb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -92,6 +92,7 @@ Subscriptions.prototype.subscribe = function(req, callback) {
     var a = url.resolve(origin, req.baseUrl);
     var b = url.resolve(a, URL);
     URL = b;
+    console.log('DEBUG URL IS', URL);
   } else {
     protocol = protocol[1]
   }
@@ -294,7 +295,11 @@ function PollingSocket(url, req, interval, config) {
         console.log('Error polling: ' + url);
       } else {
         if (!self.isClosed) {
-          self.poll = setTimeout(pollServer, 1000 || interval);
+          if(process.env.DISABLE_POLLING != "TRUE") {
+            self.poll = setTimeout(pollServer, 1000 || interval);
+          } else {
+            console.log('Polling is disabled. Finishing request.')
+          }
           var data = response.body;
           if (self.onmessage) {
             self.onmessage(data);