The server object is a singleton which provides functionality for controlling and communicating with the Electric Imp impCloud™ server. It is instantiated automatically when the Squirrel virtual machine starts. A connection to the server is required for the device to communicate with its agent, but the server object does not refer to the agent itself, rather to the infrastructure which supports the agent. To interact with the agent specifically, use the agent object.
All methods that send data to the server return 0 on success, or a Send Error Code:
|Error Code Constant||Value||Description|
|SEND_ERROR_NOT_CONNECTED||1||There is no connection to the server|
|SEND_ERROR_TIMEOUT||2||The timeout expired before all the data was sent to the server|
|SEND_ERROR_DISCONNECTED||3||The connection was disconnected before all data was sent to the server|
|SEND_ERROR_WOULDBLOCK||4||The data to be sent would not fit in the send buffer|
The values assigned to the constants may change in a future impOS release.
For more information on managing planned disconnections and dealing with unexpected breaks in connectivity, please see How To Run An imp-enabled Device Offline.
For sample code that can be used to manage sudden losses of connectivity, see the imp API Cookbook recipe Handle Unexpected Device Disconnections.
The server object has the following member methods:
The server object also has the following deprecated member methods, which should not be used in new code, but are documented here as an aid to understanding and migrating old code:
The server object also has the following deprecated member property, which should not be used in new code, but are documented here as an aid to understanding and migrating old code: