CanIOResponse
Class Overview
Use this class to create and send a response from one peer to another, in response to an incoming CanIORequest.
Each response can contain an NSData object of any size, as well as a set of JSON-encodable key-value pairs.
Each response has packetType property, used to identify the response's purpose within your app. The receiving peer receives the same CanIOResponse object, and can read its data, responseJSON and packetType propeties.
Each response is matched to its originating request through the sequence property, which is identical in the request and response.
Properties
@property (nonatomic, assign) int64_t packetType;
The response's packetType (readonly)
@property (nonatomic, assign) int64_t sequence;
The response's sequence number, used to match it to its request which should have the same sequence number.
@property (nonatomic, copy) NSString *appName;
The name of the app from which the response originates.
@property (nonatomic, copy) NSString *peerName;
@property (nonatomic, copy) NSString *peerUUID;
The name and UUID of the peer from which the response originates.
@property (nonatomic) NSMutableDictionary *responseJSON;
A dictionary containing a set of JSON-encodable key values which can be included in the response. Add key-value pairs to this dictionary after initiating the response.
@property (nonatomic) NSData *data;
The response's data.
Methods
- (id)initWithData:(NSData *)data packetType:(int64_t)packetType forRequest:(CanIORequest *)request;
Use this method to init a new response, passing on the response's data, its packettype, and the request from which it originated. After initiaiting the response, you may optionaly add more key-value pairs to its responseJSON property to include those key-values in the response.
For example:
CanIORequest *myResponse = [[CanIOResponse alloc] initWithData:myData packetType:kContactPacketType forRequest:incomingRequest];
myResponse.responseJSON["contact_name"] = @"John Smith";