Skip to content

Instantly share code, notes, and snippets.

@mlabbe
Created January 14, 2015 07:21
Show Gist options
  • Select an option

  • Save mlabbe/9e24ab3ec9eca4eaca1d to your computer and use it in GitHub Desktop.

Select an option

Save mlabbe/9e24ab3ec9eca4eaca1d to your computer and use it in GitHub Desktop.
Claypot Client Posting to HTTP Queue
void OnClaypotHTTPResponse( const HTTP &http, void *datum )
{
HTTPError httpError;
Message("HTTP Queue callback. Response Code: %i: %s\n",
httpError.GetStatusCode(), httpError.GetStatusString() );
}
void PostClaypotEvent( const char *eventName,
const Dict &eventKeys,
unsigned long tsOffset,
URL &claypotServer,
const char *ipSalt,
HTTPQueue &hq )
{
ClaypotEvent event;
event.Set( eventname, eventKeys, tsOffset );
// Use the single-event posting interface
size_t requestBytes;
const char *resource = event.GetURLResource();
const char *requestBody = event.GetHTTPRequestBody(&requestBytes, ipSalt);
claypotServer.SetResource( resource );
HTTP::Request request;
request.Set( requestBody, requestBytes );
request.AddHeader( "User-Agent", "Frogtoss Claypot Client" );
hq.AddPostRequest(request, OnClaypotHTTPResponse);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment