Integratec API Platform
C

Open

// Import the wrapper
#include "opApi.h"
// Include stddef.h to get declaration for NULL
#include <stddef.h>
// Open a connection
OPAPIHandle api;
wchar_t *brokerId = NULL;
wchar_t *errorMsg = NULL;
opClientConnectionOpen(L"127.0.0.1", 60000, NULL, &api, &brokerId, &errorMsg);

SendRequest

// Set input params
wchar_t *serviceId = L"getBrokerIdentity";
wchar_t *requestJson = L"{}";
// Generate a request
wchar_t *guid;
wchar_t *errorMsg;
opClientConnectionSendRequest(api, serviceId, requestJson, &guid, &errorMsg);

ReceiveReply

// Get the reply for the specified request ID with a timeout of 100ms
wchar_t *replyJson;
wchar_t *errorMsg;
opClientConnectionReceiveReply(api, guid, 100, &replyJson, &errorMsg);

DeleteRequest

// Clean up record of the specified request
wchar_t *errorMsg;
opClientConnectionDeleteRequest(api, guid, &errorMsg);

SendRecvDelete

// Create a request, get the reply, and clean up the request
opClientConnectionSendRecvDelete(api, serviceId, requestJson, 100, &replyJson, &errorMsg);

Close

// Close the client connection

Status Callback

// Include stdio.h to get declaration for wprintf()
#include <stdio.h>
// Implement an example callback to print the id and status given by status
void _statusCallback(OPAPIHandle sender, wchar_t *id, wchar_t *status)
{
wprintf(L"The status of id {%ws} is {w%s}.", id, status);
}
void main()
{
// Pass in the status callback pointer argument
OPAPIHandle api;
wchar_t *brokerId;
wchar_t *errorMsg;
opClientConnectionOpen(L"127.0.0.1", 60000, &_statusCallback, &api, &brokerId, &errorMsg);
}