Fixing websocket demos for stricter subprotocol checks in Chrome 30
This commit is contained in:
parent
b5345caed1
commit
ead66cd422
|
@ -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<>();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue