Fixing websocket demos for stricter subprotocol checks in Chrome 30

This commit is contained in:
Joakim Erdfelt 2013-11-15 09:26:35 -07:00
parent b5345caed1
commit ead66cd422
2 changed files with 7 additions and 2 deletions

View File

@ -31,7 +31,7 @@ import javax.websocket.RemoteEndpoint;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
@ServerEndpoint(value="/javax.websocket/")
@ServerEndpoint(value="/javax.websocket/", subprotocols={"chat"})
public class JavaxWebSocketChat
{
private static final List<JavaxWebSocketChat> members = new CopyOnWriteArrayList<>();

View File

@ -73,7 +73,12 @@ public class WebSocketChatServlet extends WebSocketServlet implements WebSocketC
@Override
public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
{
return new ChatWebSocket();
if (req.hasSubProtocol("chat"))
{
resp.setAcceptedSubProtocol("chat");
return new ChatWebSocket();
}
return null;
}
@Override