Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag created socket on Android #527

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

package io.crossbar.autobahn.websocket;

import android.net.TrafficStats;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
Expand Down Expand Up @@ -56,6 +58,8 @@

public class WebSocketConnection implements IWebSocket {

private static final int THREAD_SOCKET_TAG = 1000;

private static final IABLogger LOGGER = ABLogger.getLogger(WebSocketConnection.class.getName());

private IThreadMessenger mMessenger;
Expand Down Expand Up @@ -120,6 +124,9 @@ private class WebSocketConnector extends Thread {
public void run() {
Thread.currentThread().setName("WebSocketConnector");

// tag the thread for socket traffic monitoring
TrafficStats.setThreadStatsTag(THREAD_SOCKET_TAG);

/*
* connect TCP socket
*/
Expand All @@ -144,6 +151,9 @@ public void run() {
mSocket.setSoTimeout(mOptions.getSocketReceiveTimeout());
mSocket.setTcpNoDelay(mOptions.getTcpNoDelay());

// tag socket for monitoring
TrafficStats.tagSocket(mSocket);

} catch (IOException e) {
mMessenger.notify(new CannotConnect(e.getMessage()));
return;
Expand Down