TRCConnection provides abstraction over network connection. More...

Instance Methods | |
| (NSMutableURLRequest *) | - requestWithOptions:error: |
Creates NSURLRequest using information from TRCRequest. More... | |
| (id< TRCProgressHandler >) | - sendRequest:withOptions:completion: |
Sends NSURLRequest via network, then handles response using options.responseBodySerialization or writes into options.outputStream. More... | |
| (TRCConnectionReachabilityState) | - reachabilityState |
| Returns current reachability state if implemented. More... | |
| (void) | - setReachabilityDelegate: |
Sets TRCConnectionReachabilityDelegate, which used to get notified about reachabilityState changes. More... | |
TRCConnection provides abstraction over network connection.
TyphoonRestClient instance uses connection to two main tasks:
requestWithOptions:error: methodsendRequest:withOptions:completion: methodYou can use default implementation of TRCConnection protocol, which uses AFNetworking library (see TRCConnectionAFNetworking). It's also useful to inject your own connection between TyphoonRestClient and real TRCConnection, to listen all network events, and modify request if needed. For example TRCConnectionLogger just prints any network activity into log.
| - (NSMutableURLRequest *) requestWithOptions: | (id< TRCConnectionRequestCreationOptions >) | options | |
| error: | (NSError **) | requestComposingError | |
Creates NSURLRequest using information from TRCRequest.
TyphoonRestClient handles TRCRequest and collect all necessary info into special, easy-to-use object of <TRCConnectionRequestCreationOptions> protocol.
Notice, that return value is mutable NSMutableURLRequest. That useful for connections-in-the-middle to modify request made by real network connection (usually used to add additional headers)
| options | contains all information required to compose NSURLRequest |
| requestComposingError | pointer to NSError object. Write your error object into that pointer, if you can't create NSURLRequest and return nil |
| - (id<TRCProgressHandler>) sendRequest: | (NSURLRequest *) | request | |
| withOptions: | (id< TRCConnectionRequestSendingOptions >) | options | |
| completion: | (TRCConnectionCompletion) | completion | |
Sends NSURLRequest via network, then handles response using options.responseBodySerialization or writes into options.outputStream.
TyphoonRestClient makes TRCConnectionRequestSendingOptions using TRCRequest. These send options contains all necessary information to send request and handle response.
Note that this method should return object that confirms <TRCProgressHandler> protocol, so caller can track upload and download progress. (Implemented in TRCConnectionAFNetworking)
| request | request to send via network |
| options | contains information required to send request and handle response |
| completion | block that contains result, response information and error arguments. Note that completion block is not retained, so it's not necessary to put weak varies inside. |
|
optional |
Returns current reachability state if implemented.
If not implemented, treats as TRCConnectionReachabilityStateUnknown
|
optional |
Sets TRCConnectionReachabilityDelegate, which used to get notified about reachabilityState changes.
Used by TyphoonRestClient, which post TyphoonRestClientReachabilityDidChangeNotification after each changing