@Override
public Action service(AtmosphereRequest req, AtmosphereResponse res)
throws IOException, ServletException {
Action action = null;
Boolean b = (Boolean) req.getAttribute(WebSocket.WEBSOCKET_INITIATED);
if (b == null) b = Boolean.FALSE;
if (!Utils.webSocketEnabled(req) && req.getAttribute(WebSocket.WEBSOCKET_ACCEPT_DONE) == null) {
if (req.resource() != null && req.resource().transport() == AtmosphereResource.TRANSPORT.WEBSOCKET) {
WebSocket.notSupported(req, res);
return Action.CANCELLED;
} else {
return super.service(req, res);
}
} else {
if (webSocketFactory != null && !b) {
req.setAttribute(WebSocket.WEBSOCKET_INITIATED, true);
webSocketFactory.acceptWebSocket(req, res);
req.setAttribute(WebSocket.WEBSOCKET_ACCEPT_DONE, true);
return new Action();
}
action = suspended(req, res);
if (action.type() == Action.TYPE.SUSPEND) {
} else if (action.type() == Action.TYPE.RESUME) {
req.setAttribute(WebSocket.WEBSOCKET_RESUME, true);
}
}
return action == null ? super.service(req, res) : action;