public class WebSocketChatServlet extends WebSocketServlet implements WebSocketCreator
Modifier and Type | Class and Description |
---|---|
class |
WebSocketChatServlet.ChatWebSocket
Create a WebSocket that echo's back the message to all other members of the servlet.
|
Modifier and Type | Field and Description |
---|---|
private java.util.List<WebSocketChatServlet.ChatWebSocket> |
members
Holds active sockets to other members of the chat
|
Constructor and Description |
---|
WebSocketChatServlet() |
Modifier and Type | Method and Description |
---|---|
void |
configure(WebSocketServletFactory factory) |
java.lang.Object |
createWebSocket(ServletUpgradeRequest req,
ServletUpgradeResponse resp)
Create a websocket from the incoming request.
|
protected void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
destroy, init, service
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
private final java.util.List<WebSocketChatServlet.ChatWebSocket> members
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doGet
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException
public java.lang.Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
WebSocketCreator
createWebSocket
in interface WebSocketCreator
req
- the request detailsresp
- the response detailspublic void configure(WebSocketServletFactory factory)
configure
in class WebSocketServlet