Typedefs

GCDWebServerAsyncStreamBlock

void(^)(GCDWebServerBodyReaderCompletionBlock completionBlock)

The GCDWebServerAsyncStreamBlock works like the GCDWebServerStreamBlock except the streamed data can be returned at a later time allowing for truly asynchronous generation of the data.

The block must call "completionBlock" passing the new chunk of data when ready, an empty NSData when done, or nil on error and pass a NSError.

The block cannot call "completionBlock" more than once per invocation.

GCDWebServerBodyReaderCompletionBlock

void(^)(NSData *data, NSError *error)

The GCDWebServerBodyReaderCompletionBlock is passed by GCDWebServer to the GCDWebServerBodyReader object when reading data from it asynchronously.

GCDWebServerMatchBlock

)(NSString *requestMethod, NSURL *requestURL, NSDictionary *requestHeaders, NSString *urlPath, NSDictionary *urlQuery)

The GCDWebServerMatchBlock is called for every handler added to the GCDWebServer whenever a new HTTP request has started (i.e. HTTP headers have been received). The block is passed the basic info for the request (HTTP method, URL, headers...) and must decide if it wants to handle it or not.

If the handler can handle the request, the block must return a new GCDWebServerRequest instance created with the same basic info. Otherwise, it simply returns nil.

GCDWebServerCompletionBlock

void(^)(GCDWebServerResponse *response)

The GCDWebServerAsynchronousProcessBlock works like the GCDWebServerProcessBlock except the GCDWebServerResponse can be returned to the server at a later time allowing for asynchronous generation of the response.

The block must eventually call "completionBlock" passing a GCDWebServerResponse or nil on error, which will result in a 500 HTTP status code returned to the client. It's however recommended to return a GCDWebServerErrorResponse on error so more useful information can be returned to the client.

GCDWebServerProcessBlock

)(GCDWebServerRequest *request)

The GCDWebServerProcessBlock is called after the HTTP request has been fully received (i.e. the entire HTTP body has been read). The block is passed the GCDWebServerRequest created at the previous step by the GCDWebServerMatchBlock.

The block must return a GCDWebServerResponse or nil on error, which will result in a 500 HTTP status code returned to the client. It's however recommended to return a GCDWebServerErrorResponse on error so more useful information can be returned to the client.

GCDWebServerStreamBlock

NSData *(^)(NSError **error)

The GCDWebServerStreamBlock is called to stream the data for the HTTP body. The block must return either a chunk of data, an empty NSData when done, or nil on error and set the "error" argument which is guaranteed to be non-NULL.

FailureBlock

void(^)(NSError *error)

Generic asynchronous operation response error handler block. In all cases, you will get a valid NSError object. Connect SDK will make all attempts to give you the lowest-level error possible. In cases where an error is generated by Connect SDK, an enumerated error code (ConnectStatusCode) will be present on the NSError object.

Low-level error example

Situation

Connect SDK receives invalid XML from a device, generating a parsing error

Result

Connect SDK will call the FailureBlock and pass off the NSError generated during parsing of the XML.

High-level error example

Situation

An invalid value is passed to a device capability method

Result

The capability method will immediately invoke the FailureBlock and pass off an NSError object with a status code of ConnectStatusCodeArgumentError.

  • error

    NSError object describing the nature of the problem. Error descriptions are not localized and mostly intended for developer use. It is not recommended to display most error descriptions in UI elements.

SuccessBlock

void(^)(id responseObject)

Generic asynchronous operation response success handler block. If there is any response data to be processed, it will be provided via the responseObject parameter.

  • responseObject

    Contains the output data as a generic object reference. This value may be any of a number of types (NSString, NSDictionary, NSArray, etc). It is also possible that responseObject will be nil for operations that don't require data to be returned (move mouse, send key code, etc).