CanIORequest

Class Overview

Use this class to create and send a request from one peer to another. Each request can contain an NSData object of any size, as well as a set of JSON-encodable key-value pairs.

Each request has packetType property, used to identify the request's purpose within your app. The receiving peer receives the same CanIORequest object, and can read its data, requestJSON and packetType propeties.

Properties

@property (nonatomic, assign) int64_t packetType;

The request's packetType (readonly)

@property (nonatomic, assign) int64_t sequence;

The request's sequence number, used to match it to its response which should have the same sequence number.

@property (nonatomic, copy) NSString *appName;

The name of the app from which the request originates.

@property (nonatomic, copy) NSString *peerName;
@property (nonatomic, copy) NSString *peerUUID;

The name and UUID of the peer from which the request originates.

@property (nonatomic) NSMutableDictionary *requestJSON;

A dictionary containing a set of JSON-encodable key values which can be included in the request. Add key-value pairs to this dictionary after initiating the request.

@property (nonatomic) NSData *data;

The request's data.

Methods

- (id)initWithData:(NSData *)data packetType:(int64_t)packetType;

Use this method to init a new request, passing on the request's data and its packettype. After initiaiting the request, you may optionaly add more key-value pairs to its requestJSON property to include those key-values in the request.

For example:

CanIORequest *myRequest = [[CanIORequest alloc] initWithData:myData packetType:kContactPacketType];
myRequest.requestJSON["contact_name"] = @"John Smith";