public class NetworkTestHandler
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
NetworkTestHandler.MessageType
Message types sent to JS client.
|
private static class |
NetworkTestHandler.State
All possible states the instance may be in.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.Thread |
downloadThread
download thread
|
private boolean |
downloadThreadInterrupt
download thread interrupt signal
|
private NetworkTestHandler.State |
state
Handler state
|
private int |
transferredBytes
Amount of transferred bytes during testing
|
private long |
uploadStartNanos
Upload test start timestamp
|
private long |
uploadStopNanos
Upload test stop timestamp
|
private WebClientProtocol |
webClientProtocol
web client protocol
|
Constructor and Description |
---|
NetworkTestHandler(WebClientProtocol webClientProtocol)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
handle(byte[] message,
int offset)
Web socket message handler.
|
private void |
handleNoiseData(int noiseSize)
Handles incoming test data.
|
private void |
handlePing()
Handles ping message.
|
private void |
sendUploadStatistics()
Sends upload statistics to JS client.
|
private void |
startDownloadTest(int contentSize,
int durationSecs)
Starts download test.
|
private void |
startUploadTest()
Marks start of upload test.
|
private void |
stopDownloadTest()
Stops running download test.
|
private void |
stopTest()
Stops any currently active test.
|
private WebClientProtocol webClientProtocol
private java.lang.Thread downloadThread
private volatile boolean downloadThreadInterrupt
private volatile NetworkTestHandler.State state
private int transferredBytes
private long uploadStartNanos
private long uploadStopNanos
public NetworkTestHandler(WebClientProtocol webClientProtocol)
webClientProtocol
- Web client protocol.public void handle(byte[] message, int offset)
message
- Message data.offset
- Message offset.private void handleNoiseData(int noiseSize)
noiseSize
- Test data size.private void handlePing()
private void startUploadTest()
private void sendUploadStatistics()
private void startDownloadTest(int contentSize, int durationSecs)
contentSize
- Size of message content sent to JS client.durationSecs
- The test duration.private void stopDownloadTest()
private void stopTest()