# File lib/skinny.rb, line 209
    def handshake!
      if hixie_76?
        [key1, key2].each { |key| raise WebSocketProtocolError, "Invalid key: #{key}" if key >= 2**32 }
        raise WebSocketProtocolError, "Invalid challenge: #{key3}" if key3.length < 8
      end

      send_data handshake

      @state = :handshook

      EM.next_tick { callback :on_handshake, self rescue error! "Error in handshake callback" }
    rescue
      error! "Error during WebSocket connection handshake"
    end