I am using the AndroidAsync library from GitHub that is provided by koush. I need this library to create a WebSocket server and I was able to create it.
private static List<WebSocket> webSockets = new ArrayList<WebSocket>();
private static AsyncHttpServer httpServer = new AsyncHttpServer();
Here's the implementation:
public static void createWebSocket() {
httpServer.websocket("/", new AsyncHttpServer.WebSocketRequestCallback() {
@Override
public void onConnected(final WebSocket webSocket, AsyncHttpServerRequest request) {
webSockets.add(webSocket);
webSocket.setClosedCallback(new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
Log.d(TAG, "onCompleted");
}
});
webSocket.setStringCallback(new WebSocket.StringCallback() {
@Override
public void onStringAvailable(String s) {
Log.d(TAG, "onStringAvailable");
}
});
}
});
httpServer.listen(8080);
}
This implementation works completely fine.
But I want to use the wss
protocol where I can use a JKS (Java KeyStore) certificate for the websocket.
Is there any way to do this? If not with this library, is there any other library I can use? Any example would be really appreciated.
Thank you!!