@ServerEndpoint("/echo") public class EchoEndpoint { @OnMessage public void onMessage(Session session, String msg) { try { session.getBasicRemote().sendText(msg); } catch (IOException e) { ... } } }
Annotation | Event | Example |
---|---|---|
|
Connection opened |
@OnOpen public void open(Session session, EndpointConfig conf) { } |
|
Message received |
@OnMessage public void message(Session session, String msg) { } |
|
Connection error |
@OnError public void error(Session session, Throwable error) { } |
|
Connection closed |
@OnClose public void close(Session session, CloseReason reason) { } |