User:Ssalkeld/sandbox

h1. HangerMessage

A _HangerMessage_ is constructed of two parts, the Header and the Payload. The message and its components are described explicitly using XDR notation ("See RFC4506":http://tools.ietf.org/html/rfc4506).

struct {   opaque header<>; opaque payload<>; } HangerMessage;

Since both the header and payload are packed as opaque, lengths are automatically included as unsigned ints at the front of each.

h2. HangerHeader

The header of every _HangerMessage_ consists of the following definition:

struct {    unsigned int requestId; unsigned int messageAndResourceType; } HangerHeader;

Where
 * *requestId* - If the message is a part of a response to a client request, the *requestId* will be the non-zero numeric ID provided by the client to uniquely identify the request and related responses. A value of zero (0x00) indicates that the message is server generated and not related to an existing client request such as a PUSH notification.
 * *messageAndResourceType* - Is a value which identifies the type of message and optionally the type of resource contained within the message. The value is calculated by adding the appropriate HangerMessageType and HangerResourceType.  See description of HangerMessageType and HangerResourceType for more information regarding these values.

h3. HangerMessageType

_HangerMessageType_ consists of the following definition:


 * HangerMessageType*|*Code*|*Description*|
 * HangerMessageData|0x01000000|Indicates that the message contains data of a response to a client initiated request.|
 * HangerMessageDataEnd|0x81000000|HangerMessageData which indicates the end of response to a client request.|
 * HangerMessageError|0x02000000|Contains an error encountered by the server while processing the request.|
 * HangerMessageErrorEnd|0x82000000|HangerMessageError which indicates the end of response to a client request.|
 * HangerMessageAlert|0x83000000|Message initiated by a server event (i.e. not a response to a client request).|
 * HangerMessageEnd|0x80000000|Indicates the end of a response to a client's request.|

The values of a HangerMessageType enumeration must be within the range of _0x01000000_ and _0xff000000_.

h3. HangerResourceType

_HangerResourceType_ consists of the following XDR definition:

enum {  HangerResourceTypeApplication       = 0x0100, HangerResourceTypeDevice           = 0x0200, HangerResourceTypeMobileProduct    = 0x0300, HangerResourceTypePackage          = 0x0400, HangerResourceTypeMOTD             = 0x0500,

/* Pages */ HangerResourceTypePage             = 0x0601, HangerResourceTypeSourcesPage      = 0x0602, HangerResourceTypeGridPage         = 0x0603, HangerResourceTypeStaticPage       = 0x0604,

/* Sources */ HangerResourceTypeSource           = 0x0701, HangerResourceTypeVideoSource      = 0x0702, HangerResourceTypeTwitterSource    = 0x0703,

/* Stories */ HangerResourceTypeStory            = 0x0800, HangerResourceTypeMediaStory       = 0x0801, HangerResourceTypeTwitterStory     = 0x0802,

/* Search Types */ HangerResourceTypeSearchMetadata = 0x0900, HangerResourceTypeFacetValue = 0x0a00, } HangerResourceType;

The values of a HangerResourceType enumeration must be within the range of _0x00000001_ and _0x00ffffff_.

h2. HangerPayload

The payload is an unordered series of _HangerParam_ data and is terminated with the parameter _HangerParamIdEOM_ with a value of _0xdeadfeed_. _HangerParam_ consist of the following XDR definition:

struct {  HangerParam  parameter; } HangerPayload;

union switch (HangerParamId paramId) {  case HangerParamIdDate: unsigned int        date; HangerParam         next;

case HangerParamIdResourceID: string              resourceId; HangerParam         next;

case HangerParamIdResourceType: HangerResourceType  resourceType; HangerParam         next;

case HangerParamIdResourceStatus: HangerResourceStatus resourceStatus; HangerParam         next;

case HangerParamIdResourceLimitCount: unsigned int        resourceLimitCount; HangerParam         next;

case HangerParamIdResourceLimitDays: unsigned int        resourceLimitDays; HangerParam         next;

case HangerParamIdResourceCode: string              resourceCode; HangerParam         next;

case HangerParamIdResourceName: string              resourceName; HangerParam         next;

case HangerParamIdResourceCreatedAt: unsigned int        resourceCreatedAt; HangerParam         next;

case HangerParamIdResourceClass: string              resourceStoryClassName; HangerParam         next;

case HangerParamIdResultCode: HangerResultCode    resultCode; HangerParam         next;

case HangerParamIdEOM: const unsigned int  eom = 0xdeadfeed; void;

default: void;

} HangerParam;

h3. HangerParamId

_HangerParamId_ consists of the following XDR definition:


 * Param Name*|*Code*|*Type*|*Description*|
 * HangerParamString|@0x000b@|HangerParamTypeString|
 * HangerParamImage|@0x000d@|HangerParamTypeImage|
 * HangerParamId|@0x010b@|HangerParamTypeString|This is the Identifier for any and all objects|
 * HangerParamIdResourceType|@0x0203@|HangerparamEnumeration|
 * HangerParamIdName|@0x030b@|HangerParamTypeString|
 * HangerParamIdCode|@0x040b@|HangerParamTypeString|
 * HangerParamIdDescription|@0x050b@|HangerParamTypeString|
 * HangerParamIdDate|@0x060c@|HangerParamTypeDate|
 * HangerParamIdCreatedAt|@0x090c@|HangerParamTypeDate|
 * HangerParamIdStatus|@0x0a03@|HangerparamEnumeration|
 * HangerParamIdCurrentVersion|@0x0b02@|HangerParamUint|
 * HangerParamIdCompatibleVersion|@0x0c02@|HangerParamTypeUint|
 * HangerParamIdErrorCode|@0x0402@|HangerParamTypeUint|
 * HangerParamIdErrorMsg|@0x0d0b@|HangerParamTypeString|
 * HangerParamIdCount|@0x0e02@|HangerParamTypeUint|
 * HangerParamIdFacet|@0x0f0b@|HangerParamTypeString|
 * Story Related*|
 * HangerParamIdHeadline|@0x070b@|HangerParamTypeString|
 * HangerParamIdPublicationName|@0x080b@|HangerParamTypeString|
 * HangerParamIdAuthRank|@0x1002@|HangerParamTypeUint|
 * HangerParamIdByline|@0x110b@|HangerParamTypeString|
 * HangerParamIdCategories|@0x128b@|Array|
 * HangerParamIdCompanyTickers|@0x138b@|Array|
 * HangerParamIdExcerpt|@0x140b@|HangerParamTypeString|
 * HangerParamIdExternalId|@0x150b@|HangerParamTypeString|
 * HangerParamIdLanguage|@0x160b@|HangerParamTypeString|
 * HangerParamIdLocation|@0x170b@|HangerParamTypeString|
 * HangerParamIdLocations|@0x188b@|Array|
 * HangerParamIdOrganizations|@0x198b@|Array|
 * HangerParamIdPeople|@0x1a8b@|Array|
 * HangerParamIdPermalink|@0x1b0b@|HangerParamTypeString|
 * HangerParamIdProviderCategories|@0x1c8b@|Array|
 * HangerParamIdProviderTickers|@0x1d8b@|Array|
 * HangerParamIdPubType|@0x1e0b@|HangerParamTypeString|
 * HangerParamIdPublication|@0x1f0b@|HangerParamTypeString|
 * HangerParamIdReceivedAt|@0x200c@|HangerParamTypeDate|
 * HangerParamIdSource|@0x210b@|HangerParamTypeString|
 * HangerParamIdSubheadline|@0x220b@|HangerParamTypeString|
 * HangerParamIdThumbAspectRatio|@0x230b@|HangerParamTypeString|
 * HangerParamIdThumbUrl|@0x240b@|HangerParamTypeString|
 * HangerParamIdVersion|@0x2502@|HangerParamTypeUint|
 * Message Related*|
 * HangerParamIdEOM|@0xffffff02@|HangerParamTypeInt|


 * Note*: the last byte of the ID references the parameter type (HangerParamType).

h3. HangerParamType

_HangerParamType_ consists of the following XDR definition: