Receive emails with the Java EE Websocket API

I am currently working with a reference implementation of the Tyrus Java Websocket API. I have successfully created a server endpoint that receives binary messages, text messages, and pong messages, but I'm stuck trying to get it to receive ping messages. I looked at most of the Tyrus source code and read the Jave EE Websocket tutorial, but did not demonstrate functionality for receiving emails (only for sending them). Does anyone know if this is possible with the current API? If not, could you point me in the right direction to receive ping messages?

+4
source share
1 answer

You cannot process ping messages. The JSR 356 specification (Java API for WebSocket) indicates that the implementation should always respond to ping, without giving the application any opportunity to interact with these requests.

You can send pings and consume pong only:

@OnMessage
public void onPong(PongMessage pongMessage) {
    //...
}

Why do you want to do this?

+3
source

Source: https://habr.com/ru/post/1546038/


All Articles