allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.cuihp:AutobahnWebsocket:V1.0'
}
WebSocketConnection webSocketConnection = new WebSocketConnection();
try {
webSocketConnection.connect("ws://app.app.cc/", new WebSocketConnectionHandler() {
@Override
public void onOpen() {
Log.d(TAG, "onOpen");
}
@Override
public void onMessage(String payload) {
Log.d(TAG, payload);
}
@Override
public void onClose(int code, String reason) {
Log.d(TAG, code + ":" + reason);
}
});
} catch (WebSocketException e) {
e.printStackTrace();
}