Package org.java_websocket.handshake

Examples of org.java_websocket.handshake.ClientHandshake


                Handshakedata tmphandshake = d.translateHandshake( socketBuffer );
                if( tmphandshake instanceof ClientHandshake == false ) {
                  flushAndClose( CloseFrame.PROTOCOL_ERROR, "wrong http function", false );
                  return false;
                }
                ClientHandshake handshake = (ClientHandshake) tmphandshake;
                handshakestate = d.acceptHandshakeAsServer( handshake );
                if( handshakestate == HandshakeState.MATCHED ) {
                  resourceDescriptor = handshake.getResourceDescriptor();
                  ServerHandshakeBuilder response;
                  try {
                    response = wsl.onWebsocketHandshakeReceivedAsServer( this, d, handshake );
                  } catch ( InvalidDataException e ) {
                    flushAndClose( e.getCloseCode(), e.getMessage(), false );
                    return false;
                  } catch ( RuntimeException e ) {
                    wsl.onWebsocketError( this, e );
                    flushAndClose( CloseFrame.NEVER_CONNECTED, e.getMessage(), false );
                    return false;
                  }
                  write( d.createHandshake( d.postProcessHandshakeResponseAsServer( handshake, response ), role ) );
                  draft = d;
                  open( handshake );
                  return true;
                }
              } catch ( InvalidHandshakeException e ) {
                // go on with an other draft
              }
            }
            if( draft == null ) {
              close( CloseFrame.PROTOCOL_ERROR, "no draft matches" );
            }
            return false;
          } else {
            // special case for multiple step handshakes
            Handshakedata tmphandshake = draft.translateHandshake( socketBuffer );
            if( tmphandshake instanceof ClientHandshake == false ) {
              flushAndClose( CloseFrame.PROTOCOL_ERROR, "wrong http function", false );
              return false;
            }
            ClientHandshake handshake = (ClientHandshake) tmphandshake;
            handshakestate = draft.acceptHandshakeAsServer( handshake );

            if( handshakestate == HandshakeState.MATCHED ) {
              open( handshake );
              return true;
View Full Code Here

TOP

Related Classes of org.java_websocket.handshake.ClientHandshake

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.