Dear volumio community,
I’m haveng a hard time trying to develop java FX application which can control volumio player via it’s socket api.
Can anyone suggest which socket client is preferable to use in Java?
For now I’m trying to connect to volumio with jetty web socket client javax.websocket.WebSocketContainer.
Connection starts normaly, I’m getting connection messgae from volumio :
0{“sid”:“4zDRZQNFnEdCzHhbAABE”,“upgrades”:[],“pingInterval”:25000,“pingTimeout”:60000}40
But when I try to send any message, my connection closes right after message is sent with status message: CloseReason[1000].
Thus I have no answer back. Did anybody try to use java fx for player control?
Please take a look at my code below:
Code to connect to player
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
container.connectToServer(clientSocket, new URI("ws://192.168.1.201:3000/socket.io/?EIO=3&transport=websocket"));
callbacks to send, receive and to close connection
@OnOpen
public void onOpen(Session session) {
System.out.println("Connected to server");
this.session = session;
}
@OnMessage
public void onText(String message, Session session) {
consumer.accept(message);
System.out.println("Message received from server:" + message);
}
@OnClose
public void onClose(CloseReason reason, Session session) {
System.out.println("Closing a WebSocket due to " + reason.getReasonPhrase());
}
public void sendMessage(String str) throws IOException {
session.getBasicRemote().sendText(str);
}
Thanks for any help in advance!