Overview
Menu

Android

API Overview

API
Description
The main function of QUIC, used to create QuicCall instances and QUIC configuration and get the version number etc.
QuicCall
Manage QUIC requests.
Encapsulate requests.
Encapsulate responses.
Execute callbacks.
Get information about QUIC network status.

QuicClient

The main function of QUIC, used to create QuicCall instances and QUIC configuration and get the version number etc.
API
Description
newCall
Create a QuicCall instance.
Builder
Construct QUIC configuration .
Get the SDK version number.

newCall

Create a QuicCall instance for each QUIC request.
QuicCall newCall(QuicRequest request)
Parameter
Description
request
The request to be encapsulated. See QuicRequest.

getVersion

A static method that can get the SDK version number.
String getVersion()

Builder

QUIC configuration APIs
API
Description
Set the QUIC version.
Set the congestion control algorithm.
Set the connection timeout.
Set the total timeout for the request.
Set the idle connection timeout.
Whether to support IPv6.
build
Create QuicClient.

setQuicVersion

Set the QUIC version.
Builder setQuicVersion(int quicVersion)
Parameter
Description
quicVersion
Set the QUIC version. Supported versions: Q043, Q046, Q050, Q051, draft-29, RFC-V1 (RFC 9000).
Values:
QuicClient.QUIC_VERSION_Q43 (default)
QuicClient.QUIC_VERSION_Q46 audio/video proxy
QuicClient.QUIC_VERSION_Q50 audio/video proxy
QuicClient.QUIC_VERSION_Q51 audio/video proxy
QuicClient.QUIC_VERSION_IETF_DRAFT_29 audio/video proxy
QuicClient.QUIC_VERSION_IETF_RFC_V1 audio/video proxy

setCongestionType

Set the congestion control algorithm.
Builder setCongestionType(int congestionType)
Parameter
Description
congestionType
Supported congestion control algorithms: CubicBytes, RenoBytes, BBR, PCC, GCC.
Values:
QuicClient.CONGESTION_TYPE_BBR (default)
QuicClient.CONGESTION_TYPE_RENO_BYTES
QuicClient.CONGESTION_TYPE_BBR
QuicClient.CONGESTION_TYPE_PCC
QuicClient.CONGESTION_TYPE_GCC

setConnectTimeoutMillis

Set the connection timeout.
Builder setConnectTimeoutMillis(int connectTimeoutMillis)
Parameter
Description
connectTimeoutMillis
Set the connection timeout in milliseconds.
Default value: 60000.

setTotalTimeoutMillis

Set the total timeout that covers data read and write.
Builder setTotalTimeoutMillis(int totalTimeoutMillis)
Parameter
Description
totalTimeoutMillis
Set the total timeout in milliseconds.
Default value: 0 (no timeout).

setIdleTimeoutMillis

Set the idle connection timeout. When the timeout expires, connections are closed and cannot be reused.
Builder setIdleTimeoutMillis(int idleTimeoutMillis)
Parameter
Description
idleTimeoutMillis
The idle connection timeout in milliseconds.
Default value: 90000.

setSupportIpV6

Whether to support IPv6.
Builder setSupportIpV6(boolean supportIpV6)
Parameter
Description
supportIpV6 audio/video proxy
Whether to support IPv6. Values: true, false.
Default value: false.

build

Create QuicClient.
QuicClient build()

QuicCall

Manage QUIC requests.
API
Description
enqueue
Initiate an asynchronous QUIC network request.
cancel
Cancel requests.
Get information about QUIC network status. For more details, see QuicNetStats.

enqueue

Add an asynchronous QUIC request to the queue. You can get response from the callback function.
void enqueue(QuicCallback callback)
Parameter
Description
callback
Return response from the callback function. For more details, see QuicCallback.

cancel

Cancel requests.
void cancel()

getQuicNetStats

Get information about QUIC network status.
QuicNetStats getQuicNetStats()

QuicRequest

Request parameter
API
Description
Builder
Construct a request parameter.

Builder

API
Description
setUrl
Set the request URL.
setIp
Set the request IP.
addHeader
Add the request header
get
Set the request type to GET.
post
Set the request type to POST.
method
Set other request parameters.
build
Create a QuicRequest object.

setUrl

Set the request URL.
Builder setUrl(String url)
Parameter
Description
url
(Required) The request URL.

setIp

Set the request IP address.
Builder setIp(String ip)
Parameter
Description
ip
(Optional) If you do not use DNS resolution, set the IP address that the hostname resolves to.

addHeader

Add the request header in a key-value format.
Builder addHeader(String key, String value)
Parameter
Description
key
Key of the header.
value
Value of the header.

get

Set the request type to GET.
Builder get()

post

Set the request type to POST.
Builder post(RequestBody body)
Parameter
Description
body
Body data.

method

Construct DELETE, PUT and other requests.
Builder method(String method, RequestBody body)
Parameter
Description
method
Supported request methods: PUT, DELETE, HEAD, PATCH.
body
Body data.

build

Create QuicRequest
QuicRequest build()

QuicResponse

Response information
API
Description
getCode
Get the response status code.
Get the response headers.
Get Content-Type.
Get Content-Length.
body
Get the response body.

getCode

Get the response status code.
int getCode()

getHeaders

Get a list of response headers.
List<String> getHeaders()

getContentType

Get the content type from the response.
void setContentType(String contentType)
Parameter
Description
contentType
Get the content type.

getContentLength

Get the content length.
void setContentLength(long contentLength)
Parameter
Description
contentLength
Get the content length.

body

Get the body of the response.
ResponseBody body()

QuicCallback

Execute callbacks.
API
Description
The callback succeeded.
onFailed
The callback failed.

onResponse

The callback function to execute when the request has succeeded.
void onResponse(QuicCall call, QuicResponse response) throws IOException
Parameter
Description
call
Manage the QUIC request. For more details, see QuicCall.
response
Return the QUIC response. For more details, see QuicResponse.

onFailed

The callback function to execute when the request has failed.
void onFailed(QuicCall call, int errorCode, String errorMsg)
Parameter
Description
call
Manage the QUIC request. For more details, see QuicCall.
errorCode
The error code.
errorMsg
The error message.

QuicNetStats

Get information about QUIC network status.
API
Description
isValid
Whether the value of status is valid.
isQuic
Whether it is a QUIC request.
is0rtt
Whether it is a 0-RTT connection.
isConnReuse
Whether the connection is reused.
getConnectMs
Get the connection duration in milliseconds.
getDnsMs
Get the DNS duration in milliseconds.
getDnsCode
Get the DNS error code.
getTtfbMs
Get the time taken for the first byte to be received in milliseconds.
getCompleteMs
Get the time taken for the request to be completed in milliseconds. The time taken by the connection is not included.
getSrttMs
Get the average round-trip time in milliseconds.
getPacketsSent
Get the number of packets sent in bytes.
getPacketsRetransmitted
Get the number of packets retransmitted in bytes.
getBytesSent
Get the number of bytes sent.
getBytesRetransmitted
Get the number of bytes retransmitted.
getPacketsLost
Get the number of packets lost in bytes.
getPacketsReceived
Get the number of packets received in bytes.
getBytesReceived
Get the number of bytes received.
getStreamBytesReceived
Get the number of bytes received within the stream.