DBTransportDefaultClient
Objective-C
@interface DBTransportDefaultClient : DBTransportBaseClient <DBTransportClient>
Swift
class DBTransportDefaultClient : DBTransportBaseClient, DBTransportClient
The networking client for the User and Business API.
Normally, one networking client should instantiated per access token and session / background session pair. By
default, all Upload-style and Download-style requests are made via a background session (except when uploading via
NSInputStream
or NSData
, or downloading to NSData
, in which case, it is not possible) and all RPC-style
request are made using a foreground session.
Requests are made via one of the request methods below. The request is launched, and a DBTask
object is returned,
from which response and progress handlers can be added directly. By default, these handlers are added / executed
using the main thread queue and executed in a thread-safe manner (unless a custom delegate queue is supplied via the
DBTransportDefaultConfig
object). An internal DBDelegate
object then retrieves the appropriate handler and
executes it.
While response handlers are not optional, they do not necessarily need to have been installed by the time the SDK has received its server response. If this is the case, completion data will be saved, and the handler will be executed with the completion data upon its installation. Downloaded content will be moved from a temporary location to the final destination when the response handler code is executed.
Argument serialization and deserialization is performed with this class.
-
A serial delegate queue used for executing blocks of code that touch state shared across threads (mainly the request handlers storage).
Declaration
Objective-C
@property (nonatomic, readonly) NSOperationQueue *_Nonnull delegateQueue;
Swift
var delegateQueue: OperationQueue { get }
-
If set to true when the
DBTransportDefaultClient
object is initialized, all network requests are made on foreground sessions (by default, most upload/download operations are performed with a background session). This is appropriate for use cases where file upload / download operations will be quick, and immediate response is preferable. Otherwise, for background sessions, uploads/downloads will essentially never time out, if network connection is lost after the request has begun.Declaration
Objective-C
@property (nonatomic, readonly) BOOL forceForegroundSession;
Swift
var forceForegroundSession: Bool { get }
-
The foreground session used to make all foreground requests (RPC style requests, upload from
NSData
andNSInputStream
, and download toNSData
).Declaration
Objective-C
@property (nonatomic, strong) NSURLSession *_Nonnull session;
Swift
var session: URLSession { get set }
-
By default, the background session used to make all background requests (Upload and Download style requests, except for upload from
NSData
andNSInputStream
, and download toNSData
) unlessforceForegroundSession
is set to true, in which case, it is simply the same session as the foreground session.Declaration
Objective-C
@property (nonatomic, strong) NSURLSession *_Nonnull secondarySession;
Swift
var secondarySession: URLSession { get set }
-
The foreground session on which longpoll requests are made. Has a much longer timeout period than other sessions.
Declaration
Objective-C
@property (nonatomic, strong) NSURLSession *_Nonnull longpollSession;
Swift
var longpollSession: URLSession { get set }
-
Full constructor.
Declaration
Objective-C
- (nonnull instancetype) initWithAccessToken:(nullable NSString *)accessToken tokenUid:(nullable NSString *)tokenUid transportConfig:(nullable DBTransportDefaultConfig *)transportConfig;
Swift
init(accessToken: String?, tokenUid: String?, transport transportConfig: DBTransportDefaultConfig?)
Parameters
accessToken
The Dropbox OAuth2 access token used to make requests.
tokenUid
Identifies a unique Dropbox account. Used for the multi Dropbox account case where client objects are each associated with a particular Dropbox account.
transportConfig
A wrapper around the different parameters that can be set to change network calling behavior.
DBTransportDefaultConfig
offers a number of different constructors to customize networking settings.Return Value
An initialized instance.
-
Creates a transport config with the same settings as the current transport client, to be used to instantiate an additional network client, to perform user API actions on behalf of other team members, by a team app.
Declaration
Objective-C
- (nonnull DBTransportDefaultConfig *)duplicateTransportConfigWithAsMemberId: (nonnull NSString *)asMemberId;
Swift
func duplicateTransportConfigWith(asMemberId: String) -> DBTransportDefaultConfig
Parameters
asMemberId
The Dropbox
account_id
of the team member to perform actions on behalf of. e.g. “dbid:12345678910…”Return Value
A transport config with the same settings as the current transport client, except with information to perform actions on behalf of the team member specified by
asMemberId
. -
Creates a transport config with the same settings as the current transport client, to be used with specific path root header value.
Declaration
Objective-C
- (nonnull DBTransportDefaultConfig *)duplicateTransportConfigWithPathRoot: (nonnull DBCOMMONPathRoot *)pathRoot;
Swift
func duplicateTransportConfig(with pathRoot: DBCOMMONPathRoot) -> DBTransportDefaultConfig
Parameters
pathRoot
The value of path root object which will be used as Dropbox-Api-Path-Root header.
Return Value
A transport config with the same settings as the current transport client, except with Dropbox-Api-Path-Root header value specified by pathRoot.