java - how to configure websocket handle using class + spring 4.0.0 -
can 1 me please how configure web socket bean , handler using class base rather xml file.
<bean id="websocket" class="co.syntx.example.websocket.handler.websocketendpoint"/> <websocket:handlers> <websocket:mapping path="/websocket" handler="websocket"/> <websocket:handshake-interceptors> <bean class="co.syntx.example.websocket.handshakeinterceptor"/> </websocket:handshake-interceptors> </websocket:handlers>
thanks
do in websocketconfig.java
@configuration @enablewebsocket public class websocketconfig implements websocketconfigurer { @override public void registerwebsockethandlers(websockethandlerregistry registry) { registry.addhandler(new websocketendpoint(), "/websocket") .addinterceptors(new handshakeinterceptor()); } }
in above code, new websocketendpoint()
websocketendpoint.java
websocket handler , new handshakeinterceptor()
handshakeinterceptor.java
interceptor.
Comments
Post a Comment