DeviceAtlas Cloud .NET API  1.4.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Mobi.Mtld.DeviceAtlas.Cloud.Client Class Reference

DeviceAtlas Cloud API. This client library can be used to easily get device data from the DeviceAtlas Cloud service. To reduce cloud calls and improve performance the API locally caches the data returned from the cloud service. The caching uses the built in .NET cache backed by a file cache. More...

Public Member Functions

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 GetSendExtraHeaders ()
 Getter for the sendExtraHeaders setting. Defaults to false. If this TRUE then extra client headers are sent with each request to the service. If this is FALSE then only select headers essential for detection are sent. More...
 
void SetSendExtraHeaders (bool sendExtraHeaders)
 Setter for the sendExtraHeaders setting. Defaults to false. If this TRUE then extra client headers are sent with each request to the service. If this is FALSE then only select headers essential for detection are sent. 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 ()
 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...
 
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-pont 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 Client GetInstance ()
 Get the instance for the Client. More...
 

Public Attributes

const string API_VERSION = "1.4.2"
 API version More...
 
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 = "deviceatlascache"
 ehcache settings - cache key for cached device data ///
 
const String CACHE_NAME_SERVERS_AUTO = "servers"
 ehcache settings - cache key for cached servers ranked list ///
 
const String CACHE_NAME_SERVERS_MANUAL = "servers_manual"
 ehcache settings - cache key for cached servers manual fail-over list ///
 

Protected Member Functions

Server[] GetCachedServerList (string cacheKey)
 Get cached server list. For debugging cache contents. More...
 
Dictionary< string, string > PrepareHeaders (Dictionary< string, string > headers)
 Extract headers to be send to the cloud service from a header Map object. More...
 

Static Protected Member Functions

static Dictionary< string, string > NormaliseKeys (NameValueCollection headers)
 Normalise the keys in the passed in key value map. This lower-cases the keys, replaces "_" with "-" and removes any HTTP_ prefix. More...
 

Protected Attributes

const string DA_HEADER_PREFIX = "X-DA-"
 
const string CLIENT_COOKIE_HEADER = "Client-Properties"
 
const string REMOTE_ADDR = "Remote-Addr"
 
const string UA_HEADER = "user-agent"
 
const string COOKIE_HEADER = "cookie"
 
readonly string[] ESSENTIAL_HEADERS
 
readonly string[] ESSENTIAL_USER_AGENT_HEADERS
 
readonly string[] EXTRA_HEADERS
 
Server[] servers
 
List< string > calledServers
 
string rankingStatus
 

Detailed Description

DeviceAtlas Cloud API. This client library can be used to easily get device data from the DeviceAtlas Cloud service. To reduce cloud calls and improve performance the API locally caches the data returned from the cloud service. The caching uses the built in .NET cache backed by a file cache.

The client is queried by passing either an HttpRequest object or a collection of HTTP headers to it or a user-agent string. The device properties will then be returned.
Example 1 (the API will use headers from the current context HttpRequest object):

Client client = Client.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];

Example 2 (manually passing the HttpRequest object):

Client client = Client.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 3 (manually passing the http headers):

Client client = Client.GetInstance();
client.SetLicenceKey("DeviceAtlas-licence-key");
Hashtable results;
Dictionary&lt;string, string&gt; headers new Dictionary&lt;string, string&gt;();
// the headers can be defined in a Dictionary&lt;string, string&gt; or a NameValueCollection
// NameValueCollection headers = new NameValueCollection();
// get data by passing headers (headers named are not case sensitive and may include "_" or start with "HTTP_")
headers.Add("User-Agent", "Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95_8GB/15.0.015; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413");
headers.Add("X-Profile", "http://nds.nokia.com/uaprof/NN95_8GB-1r100.xml");
headers.Add("Accept", "text/html,text/css,multipart/mixed,application/java-archive, application/java");
headers.Add("Accept-Language", "en-us,en;q=0.5");
try{ results = client.GetDeviceData(headers); } 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 4 (manually passing the user-agent string):

Client client = Client.GetInstance();
client.SetLicenceKey("DeviceAtlas-licence-key");
Hashtable results;
string ua = "Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95_8GB/15.0.015; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413";
try{ results = client.GetDeviceData(ua); } 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

bool Mobi.Mtld.DeviceAtlas.Cloud.Client.GetAutoServerRanking ( )
inline

Getter for auto server ranking

Returns
true = the API will auto rank DeviceAtlas end-points. false = the default built-in DeviceAtlas end-points array or one provided manually will be used by the API.
int Mobi.Mtld.DeviceAtlas.Cloud.Client.GetAutoServerRankingLifetime ( )
inline

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.

Returns
Time in minutes
int Mobi.Mtld.DeviceAtlas.Cloud.Client.GetAutoServerRankingMaxFailures ( )
inline

Getter for max server failures

Returns
Cloud service timeout (seconds)
int Mobi.Mtld.DeviceAtlas.Cloud.Client.GetAutoServerRankingNumRequests ( )
inline

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.

Returns
Number or requests per end-point during auto-ranking.
string Mobi.Mtld.DeviceAtlas.Cloud.Client.GetCacheDir ( )
inline

Getter for the cache location directory.

Returns
The directory to store the cache items
Server [] Mobi.Mtld.DeviceAtlas.Cloud.Client.GetCachedServerList ( string  cacheKey)
inlineprotected

Get cached server list. For debugging cache contents.

Parameters
cacheKeycache key Client.CACHE_NAME_SERVERS_AUTO or Client.CACHE_NAME_SERVERS_MANUAL
Returns
array of Server objects or null if cache is empty
int Mobi.Mtld.DeviceAtlas.Cloud.Client.GetCacheItemExpirySeconds ( )
inline

Getter for the cache item expiry.

Returns
The number of seconds to allow before an item in the cache expires
int Mobi.Mtld.DeviceAtlas.Cloud.Client.GetCloudServiceTimeout ( )
inline

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.

Returns
Time in seconds.
string Mobi.Mtld.DeviceAtlas.Cloud.Client.GetCloudUrl ( )
inline

Get the last DeviceAtlas cloud service end-point (server) URL called to get device properties

<return> null or an URL. Null means no call to a DeviceAtlas cloud end-pointwas done probably because the data was fetched from cache. </return>

Hashtable Mobi.Mtld.DeviceAtlas.Cloud.Client.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.
Hashtable Mobi.Mtld.DeviceAtlas.Cloud.Client.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.
Hashtable Mobi.Mtld.DeviceAtlas.Cloud.Client.GetDeviceData ( NameValueCollection  headers)
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.

Parameters
headersA collection of HTTP headers {"header-name": "header-value",}
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.
Hashtable Mobi.Mtld.DeviceAtlas.Cloud.Client.GetDeviceData ( Dictionary< string, string >  headers)
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.

Parameters
headersA collection of HTTP headers {"header-name": "header-value",}
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.
Hashtable Mobi.Mtld.DeviceAtlas.Cloud.Client.GetDeviceData ( string  userAgent)
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.

Parameters
userAgentUser-agent string
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.
Hashtable Mobi.Mtld.DeviceAtlas.Cloud.Client.GetDeviceDataByHeaders ( Dictionary< string, string >  headers)
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.

Parameters
headersA Map of http headers {"header-name": "header-value",}
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.
Hashtable Mobi.Mtld.DeviceAtlas.Cloud.Client.GetDeviceDataByHeaders ( NameValueCollection  headers)
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.

Parameters
headersA Map of http headers {"header-name": "header-value",}
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.
Hashtable Mobi.Mtld.DeviceAtlas.Cloud.Client.GetDeviceDataByUserAgent ( string  userAgent)
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.

Parameters
userAgentUser-agent string
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.
static Client Mobi.Mtld.DeviceAtlas.Cloud.Client.GetInstance ( )
inlinestatic

Get the instance for the Client.

Returns
The instance of the Client
string Mobi.Mtld.DeviceAtlas.Cloud.Client.GetLicenceKey ( )
inline

Getter for licence key

Returns
The Licence key being used
bool Mobi.Mtld.DeviceAtlas.Cloud.Client.GetSendExtraHeaders ( )
inline

Getter for the sendExtraHeaders setting. Defaults to false. If this TRUE then extra client headers are sent with each request to the service. If this is FALSE then only select headers essential for detection are sent.

Returns
The sendExtraHeaders setting. Defaults to false.
int Mobi.Mtld.DeviceAtlas.Cloud.Client.GetServerPhaseOutLifetime ( )
inline

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.

Returns
Time in minutes
Server [] Mobi.Mtld.DeviceAtlas.Cloud.Client.GetServers ( )
inline

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.

Returns
Available DeviceAtlas cloud servers (list of Server objects)
Server [] Mobi.Mtld.DeviceAtlas.Cloud.Client.GetServersLatencies ( )
inline

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-pont list is found inside the cache then the end-points will be ranked and cached.

<return>A list of Server objects</return>

Server [] Mobi.Mtld.DeviceAtlas.Cloud.Client.GetServersLatencies ( int  numRequests)
inline

Get servers and their service latencies.

Parameters
numRequestsNumber of times to request from server

<return>A list of Server objects</return>

bool Mobi.Mtld.DeviceAtlas.Cloud.Client.GetTestMode ( )
inline

Getter for testMode setting. If this is TRUE then a test User-Agent will be used for the query.

Returns
The testMode setting. Defaults to false.
bool Mobi.Mtld.DeviceAtlas.Cloud.Client.GetUseCache ( )
inline

Is device data being cached by the API or not.

Returns
The useCache setting. Defaults to true.
bool Mobi.Mtld.DeviceAtlas.Cloud.Client.GetUseClientCookie ( )
inline

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

Returns
The sendExtraHeaders setting. Defaults to false
bool Mobi.Mtld.DeviceAtlas.Cloud.Client.GetUseFileCache ( )
inline

Is data being cached on the disk or not.

Returns
The useCache setting. Defaults to true.
string Mobi.Mtld.DeviceAtlas.Cloud.Client.GetVersion ( )
inline

Get the API version.

Returns
Api versiob
static Dictionary<string, string> Mobi.Mtld.DeviceAtlas.Cloud.Client.NormaliseKeys ( NameValueCollection  headers)
inlinestaticprotected

Normalise the keys in the passed in key value map. This lower-cases the keys, replaces "_" with "-" and removes any HTTP_ prefix.

Parameters
headers
Returns
Normalized headers
Dictionary<string, string> Mobi.Mtld.DeviceAtlas.Cloud.Client.PrepareHeaders ( Dictionary< string, string >  headers)
inlineprotected

Extract headers to be send to the cloud service from a header Map object.

Server [] Mobi.Mtld.DeviceAtlas.Cloud.Client.RankServers ( )
inline

If auto-ranking is on then rank the DeviceAtlas cloud end-points and put in cache.

<return>The ranked or re-ordered end-point list</return>

void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetAutoServerRanking ( bool  autoServerRanking)
inline

Setter for auto server ranking

Parameters
autoServerRankingtrue = the API must auto rank DeviceAtlas end-points. false = the API should use the built-in Server array or one which is provided to it.
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetAutoServerRankingLifetime ( int  autoServerRankListLifetime)
inline

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.

Parameters
autoServerRankListLifetimeTime in minutes
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetAutoServerRankingMaxFailures ( int  autoServerRankingMaxFailures)
inline

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.

Parameters
autoServerRankingMaxFailuresEnd-point fail tollerance during auto ranking.
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetAutoServerRankingNumRequests ( int  autoServerLatencyNumRequests)
inline

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.

Parameters
autoServerLatencyNumRequestsNumber or requests per end-point during auto-ranking.
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetCacheDir ( string  cacheDir)
inline

Setter for the cache location directory.

Parameters
cacheDirThe directory to store the cache items
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetCacheItemExpirySeconds ( int  cacheItemExpirySec)
inline

Setter for the cache item expiry.

Parameters
cacheItemExpirySecThe number of seconds to allow before an item in the cache expires
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetCloudServiceTimeout ( int  timeout)
inline

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.

Parameters
timeoutTime in seconds.
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetLicenceKey ( string  licenceKey)
inline

Setter for licence key

Parameters
licenceKeyThe licence key issued to gain access to DeviceAtlas Cloud
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetProxy ( WebProxy  proxy)
inline

Sets HTTP proxy settings for the remote requests

Parameters
proxy
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetSendExtraHeaders ( bool  sendExtraHeaders)
inline

Setter for the sendExtraHeaders setting. Defaults to false. If this TRUE then extra client headers are sent with each request to the service. If this is FALSE then only select headers essential for detection are sent.

Parameters
sendExtraHeadersTRUE if to send extra headers, FALSE to just send essential headers.
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetServerPhaseOutLifetime ( int  serverPhaseOutLifetime)
inline

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.

Parameters
serverPhaseOutLifetimeTime in minutes
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetServers ( Server[]  servers)
inline

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.

Parameters
serversAn array of Server objects, each object is a DeviceAtlas cloud end-point
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetTestMode ( bool  testMode)
inline

Setter for testMode setting. Defaults to false. If this is TRUE then a test User-Agent will be used for the query.

Parameters
testModeTRUE if test mode is on, FALSE otherwise
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetUseCache ( bool  useCache)
inline

Setter to cache or not to cache device data.

Parameters
useCacheTRUE if caching is to be used or FALSE if not
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetUseClientCookie ( bool  useClientCookie)
inline

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

Parameters
useClientCookieTRUE = use device data which is created by the DeviceAtlas JS library if exists.
void Mobi.Mtld.DeviceAtlas.Cloud.Client.SetUseFileCache ( bool  fileCache)
inline

Set if data must be cached on disk or not

Parameters
fileCacheTRUE = cache data on disk

Member Data Documentation

const string Mobi.Mtld.DeviceAtlas.Cloud.Client.API_VERSION = "1.4.2"

API version

const string Mobi.Mtld.DeviceAtlas.Cloud.Client.CLIENT_COOKIE_NAME = "DAPROPS"

Name of the cookie created by the DeviceAtlas client side component

readonly string [] Mobi.Mtld.DeviceAtlas.Cloud.Client.ESSENTIAL_HEADERS
protected
Initial value:
= {
"x-profile",
"x-wap-profile",
"x-att-deviceid",
"accept",
"accept-language",
}
readonly string [] Mobi.Mtld.DeviceAtlas.Cloud.Client.ESSENTIAL_USER_AGENT_HEADERS
protected
Initial value:
= {
"x-device-user-agent",
"x-original-user-agent",
"x-operamini-phone-ua",
"x-skyfire-phone",
"x-bolt-phone-ua",
"device-stock-ua",
"x-ucbrowser-ua",
"x-ucbrowser-device-ua",
"x-ucbrowser-device",
"x-puffin-ua",
}
readonly string [] Mobi.Mtld.DeviceAtlas.Cloud.Client.EXTRA_HEADERS
protected
Initial value:
= {
"client-ip",
"x-forwarded-for",
"x-forwarded",
"forwarded-for",
"forwarded",
"proxy-client-ip",
"wl-proxy-client-ip",
}
const string Mobi.Mtld.DeviceAtlas.Cloud.Client.KEY_PROPERTIES = "properties"

The name of the key used to lookup the device properties in the results object

const string Mobi.Mtld.DeviceAtlas.Cloud.Client.KEY_SOURCE = "source"

The name of the key used to lookup the source of data (none, cache or cloud) in the results object

const string Mobi.Mtld.DeviceAtlas.Cloud.Client.KEY_USERAGENT = "useragent"

The name of the key used to lookup the User-Agent in the results object

Server [] Mobi.Mtld.DeviceAtlas.Cloud.Client.servers
protected
Initial value:
=
{
new Server("http://region0.deviceatlascloud.com", "80"),
new Server("http://region1.deviceatlascloud.com", "80"),
new Server("http://region2.deviceatlascloud.com", "80"),
new Server("http://region3.deviceatlascloud.com", "80"),
}
const string Mobi.Mtld.DeviceAtlas.Cloud.Client.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.

const string Mobi.Mtld.DeviceAtlas.Cloud.Client.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.

const string Mobi.Mtld.DeviceAtlas.Cloud.Client.SOURCE_NONE = "none"

In the result Map, KEY_SOURCE may be set to this. Indicates that there was a problem getting device data.

const string Mobi.Mtld.DeviceAtlas.Cloud.Client.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


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