コード例 #1
0
  public void startHandshake(ClientHandshakeBuilder handshakedata)
      throws InvalidHandshakeException {
    assert (readystate != READYSTATE.CONNECTING) : "shall only be called once";

    // Store the Handshake Request we are about to send
    this.handshakerequest = draft.postProcessHandshakeRequestAsClient(handshakedata);

    resourceDescriptor = handshakedata.getResourceDescriptor();
    assert (resourceDescriptor != null);

    // Notify Listener
    try {
      wsl.onWebsocketHandshakeSentAsClient(this, this.handshakerequest);
    } catch (InvalidDataException e) {
      // Stop if the client code throws an exception
      throw new InvalidHandshakeException("Handshake data rejected by client.");
    } catch (RuntimeException e) {
      wsl.onWebsocketError(this, e);
      throw new InvalidHandshakeException("rejected because of" + e);
    }

    // Send
    write(draft.createHandshake(this.handshakerequest, role));
  }