Skip to main content

1E SDK

Creating an Offloading Target

The OffloadTarget needs to accept HTTP POSTs. If coded in .NET, it would typically be a WebApi application.

The DLL provided by the SDK is named Tachyon.SDK.Offloading.dll. After referencing the DLL from the WebApi project and importing the Tachyon.SDK.Offloading namespace, an action method that receives the posts can be as short as this:

Offloading target

        public HttpResponseMessage Post([CustomBody]byte[] responses)
        {
            if (responses == null)
            {
                return new HttpResponseMessage(HttpStatusCode.BadRequest);
            }
 
            ResponseRaw[] responseRaws = JsonResponseDeserializer.DeserializeObject(responses);
            ProcessResponses(responseRaws);
            return new HttpResponseMessage(HttpStatusCode.Accepted);
        }

The most important line is:

ResponseRaw

     ResponseRaw[] responseRaws = JsonResponseDeserializer.DeserializeObject(responses);
  • ResponseRaw - defined in the SDK DLL encapsulating raw responses offloaded from Tachyon

  • JsonResponseDeserializer.DeserializeObject - converts bytes received into raw responses, and handles decompression as required

  • [CustomBody] - captures raw posted data so it can be passed into DeserializeObject for decompression

For an explanation of why [CustomBody] is needed and why the default WebApi binding won't work as expected, read:

Accepting Raw Request Body Content with ASP.NET Web API - https://weblog.west-wind.com/posts/2013/Dec/13/Accepting-Raw-Request-Body-Content-with-ASPNET-Web-API.

In the above example, the method ProcessResponses would contain the custom code that processes the data received from Tachyon.