Indicates whether the device is currently connected to the server or not
true if the device is connected or
false if it is not
This method can be used in agent code to determine whether the imp-enabled device is currently connected to the Electric Imp impCloud™. This is typically done before attempting to send messages and data to the device — if the device is not connected, those messages will be lost.
This simple code uses device.isconnected() to change the value of the variable connectedString if the imp is online, or to leave the string with its default value if the device has gone offline.