The DeviceAtlas CloudApi Documentation  DEVICEATLAS_API_VERSION
Public Member Functions | Static Public Member Functions | List of all members
Com.DeviceAtlas.Cloud.ClientWebFramework Class Reference

This web client is an extension of the Client class to provide device identification by passing a HttpRequest object in addition to the base client's identification methods. More...

Inheritance diagram for Com.DeviceAtlas.Cloud.ClientWebFramework:
Com.DeviceAtlas.Cloud.Client

Public Member Functions

Hashtable GetDeviceData ()
 Get device data from DeviceAtlas Cloud service. (Uses headers from HttpContext.Current.Request) If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. If device data provided by "DeviceAtlas Client Side Component" exists in a cookie then cloud data will be merged with the cookie data. More...
 
Hashtable GetDeviceData (HttpRequest request)
 Get device data from DeviceAtlas Cloud service. If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. If device data provided by "DeviceAtlas Client Side Component" exists in a cookie then cloud data will be merged with the cookie data. More...
 
- Public Member Functions inherited from Com.DeviceAtlas.Cloud.Client
string GetCloudUrl ()
 Get the last DeviceAtlas cloud service end-point (server) URL called to get device properties More...
 
Server [] GetServers ()
 Getter for cloud server list. The end-points in the returned array are used for making DeviceAtlas cloud calls. The top end-point will most likely be used unless it fails and the call falls to the next end-point and so on. More...
 
void SetServers (Server[] servers)
 Setter for cloud server list. To set DeviceAtlas cloud end-points manually. The order of this array matters. While healthy the top end-point will be used. More...
 
bool GetAutoServerRanking ()
 Getter for auto server ranking More...
 
void SetAutoServerRanking (bool autoServerRanking)
 Setter for auto server ranking More...
 
int GetServerPhaseOutLifetime ()
 Getter for manual ranking server phase out Lifetime. When not auto-ranking shall the top end-point fail the list will be re-arranged and the failed end-point will be moved to the bottom. ServerPhaseOutLifetime indicated for how long should this re-arranged Server list be used over the original. More...
 
void SetServerPhaseOutLifetime (int serverPhaseOutLifetime)
 Setter for manual ranking server phase out Lifetime. When not auto-ranking shall the top end-point fail the list will be re-arranged and the failed end-point will be moved to the bottom. ServerPhaseOutLifetime indicated for how long should this re-arranged Server list be used over the original. More...
 
int GetCloudServiceTimeout ()
 Getter for cloud service timeout. If the API requests service from a DeviceAtlas end-point, shall the end-point not response in this amount of time the next end-point in the list will be used. More...
 
void SetCloudServiceTimeout (int timeout)
 Setter for cloud service timeout. If the API requests service from a DeviceAtlas end-point, shall the end-point not response in this amount of time the next end-point in the list will be used. More...
 
int GetAutoServerRankingMaxFailures ()
 Getter for max server failures More...
 
void SetAutoServerRankingMaxFailures (int autoServerRankingMaxFailures)
 Setter for max server failures. Number of times an end-point is allowed to fail during auto ranking. Failing more times and the end-pint will be excluded. More...
 
int GetAutoServerRankingNumRequests ()
 When auto ranking end-points, this number of requests will be sent to each end-point and the mean time will be used for ranking the end-point. More...
 
void SetAutoServerRankingNumRequests (int autoServerLatencyNumRequests)
 When auto ranking end-points, this number of requests will be sent to each end-point and the mean time will be used for ranking the end-point. More...
 
int GetAutoServerRankingLifetime ()
 Getter for auto ranking cached end-point list lifetime. After each auto ranking the ranked end point list will be valid for this amount of time. When the list is too old the API will rank it again unless the auto ranking is off. More...
 
void SetAutoServerRankingLifetime (int autoServerRankListLifetime)
 Setter for auto ranking cached end-point list lifetime. After each auto ranking the ranked end point list will be valid for this amount of time. When the list is too old the API will rank it again unless the auto ranking is off. More...
 
string GetLicenceKey ()
 Getter for licence key More...
 
void SetLicenceKey (string licenceKey)
 Setter for licence key More...
 
bool GetUseCache ()
 Is device data being cached by the API or not. More...
 
void SetUseCache (bool useCache)
 Setter to cache or not to cache device data. More...
 
bool GetUseFileCache ()
 Is data being cached on the disk or not. More...
 
void SetUseFileCache (bool fileCache)
 Set if data must be cached on disk or not More...
 
string GetCacheDir ()
 Getter for the cache location directory. More...
 
void SetCacheDir (string cacheDir)
 Setter for the cache location directory. More...
 
int GetCacheItemExpirySeconds ()
 Getter for the cache item expiry. More...
 
void SetCacheItemExpirySeconds (int cacheItemExpirySec)
 Setter for the cache item expiry. More...
 
bool GetTestMode ()
 Getter for testMode setting. If this is TRUE then a test User-Agent will be used for the query. More...
 
void SetTestMode (bool testMode)
 Setter for testMode setting. Defaults to false. If this is TRUE then a test User-Agent will be used for the query. More...
 
string GetVersion ()
 Get the API version. More...
 
bool GetUseClientCookie ()
 Getter for the useClientCookie setting. Defaults to true. If TRUE then if device data which is created by the DeviceAtlas client side component (JS library) exists it will be used More...
 
void SetUseClientCookie (bool useClientCookie)
 Setter for the useClientCookie setting. Defaults to true. If TRUE then if device data which is created by the DeviceAtlas client side component (JS library) exists it will be used More...
 
Hashtable GetDeviceData (NameValueCollection headers)
 Get device data from DeviceAtlas Cloud service. If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. More...
 
Hashtable GetDeviceData (Dictionary< string, string > headers)
 Get device data from DeviceAtlas Cloud service. If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. More...
 
Hashtable GetDeviceData (string userAgent)
 Get device data from DeviceAtlas Cloud service. If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. More...
 
Hashtable GetDeviceDataByUserAgent (string userAgent)
 Get device data from DeviceAtlas Cloud service. If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. More...
 
Hashtable GetDeviceDataByHeaders (Dictionary< string, string > headers)
 Get device data from DeviceAtlas Cloud service. If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. More...
 
Hashtable GetDeviceDataByHeaders (NameValueCollection headers)
 Get device data from DeviceAtlas Cloud service. If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. More...
 
Server [] GetServersLatencies ()
 Get DeviceAtlas cloud end-point list. If auto-ranking is on then the ranked end-point list is returned otherwise the manual or default original or fail-over list will be returned. If auto-ranking is on but no valid end-point list is found inside the cache then the end-points will be ranked and cached. More...
 
Server [] GetServersLatencies (int numRequests)
 Get servers and their service latencies. More...
 
Server [] RankServers ()
 If auto-ranking is on then rank the DeviceAtlas cloud end-points and put in cache. More...
 
void SetProxy (WebProxy proxy)
 Sets HTTP proxy settings for the remote requests More...
 

Static Public Member Functions

static ClientWebFramework GetInstance ()
 Get the instance for the ClientWebFramework. More...
 
- Static Public Member Functions inherited from Com.DeviceAtlas.Cloud.Client
static Client GetInstance ()
 Get the instance for the Client. More...
 

Additional Inherited Members

- Public Attributes inherited from Com.DeviceAtlas.Cloud.Client
const string TEST_USERAGENT = "Mozilla/5.0 (Linux; U; Android 2.3.3; en-gb; GT-I9100 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
 Built in test user-agent More...
 
const string CLIENT_COOKIE_NAME = "DAPROPS"
 Name of the cookie created by the DeviceAtlas client side component More...
 
const string KEY_USERAGENT = "useragent"
 The name of the key used to lookup the User-Agent in the results object More...
 
const string KEY_SOURCE = "source"
 The name of the key used to lookup the source of data (none, cache or cloud) in the results object More...
 
const string KEY_PROPERTIES = "properties"
 The name of the key used to lookup the device properties in the results object More...
 
const string SOURCE_CACHE = "cache"
 In the result Map, KEY_SOURCE may be set to this. Shows that the data source of device properties set to KEY_PROPERTIES in the result Map was cache. More...
 
const string SOURCE_CLOUD = "cloud"
 In the result Map, KEY_SOURCE may be set to this. Shows that the device properties set to KEY_PROPERTIES where queried from DA cloud service. More...
 
const string SOURCE_NONE = "none"
 In the result Map, KEY_SOURCE may be set to this. Indicates that there was a problem getting device data. More...
 
const String CACHE_NAME_SERVERS_AUTO = "servers"
 cache key for cached servers ranked list ///
 
const String CACHE_NAME_SERVERS_MANUAL = "servers_manual"
 cache key for cached servers manual fail-over list ///
 
- Static Public Attributes inherited from Com.DeviceAtlas.Cloud.Client
static readonly string API_VERSION = "2.2"
 API version More...
 

Detailed Description

This web client is an extension of the Client class to provide device identification by passing a HttpRequest object in addition to the base client's identification methods.

The client is queried by passing either an HttpRequest: Example 1

ClientWebFramework client = ClientWebFramework.GetInstance();
client.SetLicenceKey("DeviceAtlas-licence-key");
Hashtable results;
try{ results = client.GetDeviceData(Request); } catch (Exception x) { // handle exceptions etc... }
// The useragent used in the lookup
string ua = (String)results[Client.KEY_USERAGENT];
// The source of the data - cache, cloud etc
string dataSource = (String)results[Client.KEY_SOURCE];
// The actual device properties
Hashtable properties = (Hashtable)results[Client.KEY_PROPERTIES];

Example 2

ClientWebFramework client = ClientWebFramework.GetInstance();
client.SetLicenceKey("DeviceAtlas-licence-key");
Hashtable results;
try{ results = client.GetDeviceData(); } catch (Exception x) { // handle exceptions etc... }
// The useragent used in the lookup
string ua = (String)results[Client.KEY_USERAGENT];
// The source of the data - cache, cloud etc
string dataSource = (String)results[Client.KEY_SOURCE];
// The actual device properties
Hashtable properties = (Hashtable)results[Client.KEY_PROPERTIES];

Member Function Documentation

◆ GetDeviceData() [1/2]

Hashtable Com.DeviceAtlas.Cloud.ClientWebFramework.GetDeviceData ( )
inline

Get device data from DeviceAtlas Cloud service. (Uses headers from HttpContext.Current.Request) If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. If device data provided by "DeviceAtlas Client Side Component" exists in a cookie then cloud data will be merged with the cookie data.

Returns
A collection of device data as { Client.KEY_USERAGENT: "UA", Client.KEY_SOURCE: "data source", Client.KEY_PROPERTIES: {"propertyName": "PropertyVal",}, } Note that Client.KEY_PROPERTIES will not exists for not detectable data and on failures.
Exceptions
DaClientExceptionThrown when any part of detection or the API fails.

◆ GetDeviceData() [2/2]

Hashtable Com.DeviceAtlas.Cloud.ClientWebFramework.GetDeviceData ( HttpRequest  request)
inline

Get device data from DeviceAtlas Cloud service. If using cache is not turned off the device data will be cached after each cloud call, if cached data exists for a device it will be used over the cloud. If device data provided by "DeviceAtlas Client Side Component" exists in a cookie then cloud data will be merged with the cookie data.

Parameters
requestAn HttpRequest object
Returns
A collection of device data as { Client.KEY_USERAGENT: "UA", Client.KEY_SOURCE: "data source", Client.KEY_PROPERTIES: {"propertyName": "PropertyVal",}, } Note that Client.KEY_PROPERTIES will not exists for not detectable data and on failures.
Exceptions
DaClientExceptionThrown when any part of detection or the API fails.

◆ GetInstance()

static ClientWebFramework Com.DeviceAtlas.Cloud.ClientWebFramework.GetInstance ( )
inlinestatic

Get the instance for the ClientWebFramework.

Returns
The instance of the ClientWebFramework

The documentation for this class was generated from the following file: