API Changes
[iotcloud.git] / version2 / src / java / iotcloud / CloudComm.java
index 5ee249d18776a144d5fbc3ee32df8d08b32e3565..d7a01d6384f58cb40c8b21544fb2a38b6b22fca0 100644 (file)
@@ -15,6 +15,7 @@ import java.security.SecureRandom;
 
 
 class CloudComm {
+       String hostname;
        String baseurl;
        Cipher encryptCipher;
        Cipher decryptCipher;
@@ -35,8 +36,9 @@ class CloudComm {
        /**
         * Constructor for actual use. Takes in the url and password.
         */
-       CloudComm(Table _table, String _baseurl, String _password) {
+       CloudComm(Table _table, String _hostname, String _baseurl, String _password) {
                this.table = _table;
+               this.hostname = _hostname;
                this.baseurl = _baseurl;
                this.password = _password;
                this.random = new SecureRandom();
@@ -222,6 +224,15 @@ class CloudComm {
                }
        }
 
+       public boolean hasConnection() {
+               try {
+                       InetAddress address = InetAddress.getByName(hostname);
+                       return address.isReachable(TIMEOUT_MILLIS);
+               } catch (Exception e) {
+                       return false;
+               }
+       }
+
        /**
         * Method that actually handles building Slot objects from the
         * server response.  Shared by both putSlot and getSlots.
@@ -244,4 +255,8 @@ class CloudComm {
                dis.close();
                return slots;
        }
+
+
+
+
 }