public class Sender
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.ref.WeakReference<net.hockeyapp.android.metrics.Persistence> |
mWeakPersistence
Persistence object used to reserve, free, or delete files.
|
Modifier | Constructor and Description |
---|---|
protected |
Sender()
Creates and initializes a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected java.net.HttpURLConnection |
createConnection()
Create a connection to the default or user defined server endpoint.
|
protected java.lang.String |
getCustomServerURL() |
protected net.hockeyapp.android.metrics.Persistence |
getPersistence() |
protected java.io.Writer |
getWriter(java.net.HttpURLConnection connection)
Gets a writer from the connection stream (allows for test hooks into the write stream)
|
protected boolean |
isExpected(int responseCode)
Determines if an HTTP response code denotes a status which we regard as successful completion.
|
protected boolean |
isRecoverableError(int responseCode)
Determines if an HTTP response code denotes an error from which we can recover by sending the data again.
|
protected java.lang.String |
loadData(java.io.File file)
Read the contents of a file from the persistence layer.
|
protected void |
onResponse(java.net.HttpURLConnection connection,
int responseCode,
java.lang.String payload,
java.io.File fileToSend)
Callback for the http response from the sender.
|
protected void |
onUnexpected(java.net.HttpURLConnection connection,
int responseCode,
java.lang.StringBuilder builder)
Handler to be called if an unexpected response was returned from the ingestion endpoint.
|
protected void |
readResponse(java.net.HttpURLConnection connection,
java.lang.StringBuilder builder)
Reads the response from a connection.
|
protected int |
requestCount()
Getter for requestCount.
|
protected void |
send(java.net.HttpURLConnection connection,
java.io.File file,
java.lang.String persistedData)
Send a file to the ingestion endpoint.
|
protected void |
sendAvailableFiles()
Checks the persistence for available files and sends them.
|
protected void |
setCustomServerURL(java.lang.String customServerURL)
Set a custom server URL that will be used to send data to it.
|
protected void |
setPersistence(net.hockeyapp.android.metrics.Persistence persistence)
Set persistence used to reserve, free, or delete files (enables dependency injection).
|
protected void |
triggerSending()
Triggers sending of available telemetry data in an AsyncTask.
|
protected void |
triggerSendingForTesting(java.net.HttpURLConnection connection,
java.io.File file,
java.lang.String persistedData) |
protected java.lang.ref.WeakReference<net.hockeyapp.android.metrics.Persistence> mWeakPersistence
protected Sender()
protected void triggerSending()
protected void triggerSendingForTesting(java.net.HttpURLConnection connection, java.io.File file, java.lang.String persistedData)
protected void sendAvailableFiles()
protected void send(java.net.HttpURLConnection connection, java.io.File file, java.lang.String persistedData)
connection
- file
- persistedData
- protected java.lang.String loadData(java.io.File file)
file
- The file to read.protected java.net.HttpURLConnection createConnection()
protected void onResponse(java.net.HttpURLConnection connection, int responseCode, java.lang.String payload, java.io.File fileToSend)
connection
- The connection containing the response.responseCode
- The response code from the connection.payload
- the payload which generated this responsefileToSend
- reference to the file we want to sendprotected boolean isRecoverableError(int responseCode)
responseCode
- The response code to check.protected boolean isExpected(int responseCode)
responseCode
- The response code to check.protected void onUnexpected(java.net.HttpURLConnection connection, int responseCode, java.lang.StringBuilder builder)
connection
- The connection containing the response.responseCode
- The response code from the connection.builder
- A string builder for storing the response.protected void readResponse(java.net.HttpURLConnection connection, java.lang.StringBuilder builder)
connection
- the connection which will read the responsebuilder
- a string builder for storing the responseprotected java.io.Writer getWriter(java.net.HttpURLConnection connection) throws java.io.IOException
connection
- the connection to which the stream will be flushedjava.io.IOException
- Exception thrown by GZIP (used in SDK 19+)protected net.hockeyapp.android.metrics.Persistence getPersistence()
protected void setPersistence(net.hockeyapp.android.metrics.Persistence persistence)
persistence
- a persistence used to reserve, free, or delete filesprotected int requestCount()
protected java.lang.String getCustomServerURL()
protected void setCustomServerURL(java.lang.String customServerURL)
customServerURL
- URL for custom server endpoint to collect telemetry