private void writeHandshake(WebSocketOutputStream output,String key) throws WebSocketException {
  mHandshakeBuilder.setKey(key);
  String requestLine=mHandshakeBuilder.buildRequestLine();
  List<String[]> headers=mHandshakeBuilder.buildHeaders();
  String handshake=HandshakeBuilder.build(requestLine,headers);
  mListenerManager.callOnSendingHandshake(requestLine,headers);
  try {
    output.write(handshake);
    output.flush();
  }
 catch (  IOException e) {
    throw new WebSocketException(WebSocketError.OPENING_HAHDSHAKE_REQUEST_FAILURE,"Failed to send an opening handshake request to the server: " + e.getMessage(),e);
  }
}

private void writeHandshake ( WebSocketOutputStream output , String key ) throws WebSocketException { mHandshakeBuilder . setKey ( key ) ; String requestLine = mHandshakeBuilder . buildRequestLine ( ) ; List < String [ ] > headers = mHandshakeBuilder . buildHeaders ( ) ; String handshake = HandshakeBuilder . build ( requestLine , headers ) ; mListenerManager . callOnSendingHandshake ( requestLine , headers ) ; try { output . write ( handshake ) ; output . flush ( ) ; } catch ( IOException e ) { throw new WebSocketException ( WebSocketError . OPENING_HAHDSHAKE_REQUEST_FAILURE , "Failed to send an opening handshake request to the server: " + e . getMessage ( ) , e ) ; } }
send an opening handshake request to the websocket server .
