Ejemplo n.º 1
0
 @Override
 public HandshakeBuilder postProcessHandshakeResponseAsServer(
     ClientHandshake request, ServerHandshakeBuilder response) throws InvalidHandshakeException {
   response.setHttpStatusMessage("Web Socket Protocol Handshake");
   response.put("Upgrade", "WebSocket");
   response.put(
       "Connection", request.getFieldValue("Connection")); // to respond to a Connection keep alive
   response.put("WebSocket-Origin", request.getFieldValue("Origin"));
   String location = "ws://" + request.getFieldValue("Host") + request.getResourceDescriptor();
   response.put("WebSocket-Location", location);
   // TODO handle Sec-WebSocket-Protocol and Set-Cookie
   return response;
 }
Ejemplo n.º 2
0
 @Override
 public HandshakeState acceptHandshakeAsServer(ClientHandshake handshakedata) {
   if (handshakedata.hasFieldValue("Origin") && basicAccept(handshakedata)) {
     return HandshakeState.MATCHED;
   }
   return HandshakeState.NOT_MATCHED;
 }
Ejemplo n.º 3
0
 @Override
 public HandshakeState acceptHandshakeAsClient(ClientHandshake request, ServerHandshake response) {
   return request.getFieldValue("WebSocket-Origin").equals(response.getFieldValue("Origin"))
           && basicAccept(response)
       ? HandshakeState.MATCHED
       : HandshakeState.NOT_MATCHED;
 }