Search in sources :

Example 1 with AttachmentV3UploadAttributes

use of org.whispersystems.signalservice.internal.push.AttachmentV3UploadAttributes in project Signal-Android by WhisperSystems.

the class SignalServiceMessageSender method getResumableUploadSpec.

public ResumableUploadSpec getResumableUploadSpec() throws IOException {
    long start = System.currentTimeMillis();
    AttachmentV3UploadAttributes v3UploadAttributes = null;
    Log.d(TAG, "Using pipe to retrieve attachment upload attributes...");
    try {
        v3UploadAttributes = new AttachmentService.AttachmentAttributesResponseProcessor<>(attachmentService.getAttachmentV3UploadAttributes().blockingGet()).getResultOrThrow();
    } catch (WebSocketUnavailableException e) {
        Log.w(TAG, "[getResumableUploadSpec] Pipe unavailable, falling back... (" + e.getClass().getSimpleName() + ": " + e.getMessage() + ")");
    } catch (IOException e) {
        Log.w(TAG, "Failed to retrieve attachment upload attributes using pipe. Falling back...");
    }
    long webSocket = System.currentTimeMillis() - start;
    if (v3UploadAttributes == null) {
        Log.d(TAG, "Not using pipe to retrieve attachment upload attributes...");
        v3UploadAttributes = socket.getAttachmentV3UploadAttributes();
    }
    long rest = System.currentTimeMillis() - start;
    ResumableUploadSpec spec = socket.getResumableUploadSpec(v3UploadAttributes);
    long end = System.currentTimeMillis() - start;
    Log.d(TAG, "[getResumableUploadSpec] webSocket: " + webSocket + " rest: " + rest + " end: " + end);
    return spec;
}
Also used : AttachmentV3UploadAttributes(org.whispersystems.signalservice.internal.push.AttachmentV3UploadAttributes) ResumableUploadSpec(org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec) WebSocketUnavailableException(org.whispersystems.signalservice.api.websocket.WebSocketUnavailableException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 WebSocketUnavailableException (org.whispersystems.signalservice.api.websocket.WebSocketUnavailableException)1 AttachmentV3UploadAttributes (org.whispersystems.signalservice.internal.push.AttachmentV3UploadAttributes)1 ResumableUploadSpec (org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec)1