logger.warn("", ex);
}
}
addContextValue(request, IDENTITY, identity);
StatusMessage statusMessage = new StatusMessage.Builder().status(new StatusMessage.Status(200, "OK"))
.identity(identity).build();
response.setContentType("application/json");
response.getOutputStream().write(mapper.writeValueAsBytes(statusMessage));
if (r.transport() == AtmosphereResource.TRANSPORT.WEBSOCKET) {
schedule(r, identity);
}
if (!delegateHandshake) {
return Action.CANCELLED;
}
} else if (message.startsWith("{\"close\"")) {
CloseMessage c = mapper.readValue(data, CloseMessage.class);
logger.debug("Client disconnected {} with reason {}", c.getClose().getIdentity(), c.getClose().getReason());
try {
request.getSession().invalidate();
} catch (Exception ex) {
logger.warn("", ex);
}
return Action.CANCELLED;
} else {
Message swaggerSocketMessage = mapper.readValue(data, Message.class);
swaggerSocketMessage.transactionID(UUID.randomUUID().toString());
String identity = (String) getContextValue(request, IDENTITY);
if (!swaggerSocketMessage.getIdentity().equals(identity)) {
StatusMessage statusMessage = new StatusMessage.Builder().status(new StatusMessage.Status(503, "Not Allowed"))
.identity(swaggerSocketMessage.getIdentity()).build();
response.getOutputStream().write(mapper.writeValueAsBytes(statusMessage));
return Action.CANCELLED;
}