Reputation: 32321
I am working on a Existing Jetty based WebSocket code .
In the existing code , in that servlet there are two methods implemented
1. public WebSocket doWebSocketConnect()
2.protected void doGet(HttpServletRequest request, HttpServletResponse response)
As these are callback methods Could anybody please let me know what method is called first (I mean the method order )
Thanks in advance .
Upvotes: 0
Views: 752
Reputation: 49452
The WebSocketServlet in jetty-7, and jetty-8 (note: this has changed in jetty-9), has a few requirements for you.
The doWebSocketConnect(HttpServletRequest,String) needs to be implemented by you to create a WebSocket object (of your design) based on the information you can find in the HttpServletRequest. (such as host, paths, authentication, etc ...)
You can see an example of a Servlet in the test cases. http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/WebSocketCaptureServlet.java
This creates a CaptureSocket, stores it in the Servlet instance for tracking, and returns it. The CaptureSocket just stores the incoming Messages so that the test cases can validate the expectations. This isn't a particularly exciting Servlet/Socket impl.
An example of a few flavors of Echo sockets can also be found in the TestServer (also found in the test cases). http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestServer.java#n53
Upvotes: 2