def send(frame)
      emit(:frame_sent, frame)
      if frame[:type] == :data
        send_data(frame, true)

      else
        # An endpoint can end a connection at any time. In particular, an
        # endpoint MAY choose to treat a stream error as a connection error.
        if frame[:type] == :rst_stream && frame[:error] == :protocol_error
          goaway(frame[:error])
        else
          # HEADERS and PUSH_PROMISE may generate CONTINUATION. Also send
          # RST_STREAM that are not protocol errors
          frames = encode(frame)
          frames.each { |f| emit(:frame, f) }
        end
      end
    end
def send(frame)
      emit(:frame_sent, frame)
      if frame[:type] == :data
        send_data(frame, true)

      else
        # An endpoint can end a connection at any time. In particular, an
        # endpoint MAY choose to treat a stream error as a connection error.
        if frame[:type] == :rst_stream && frame[:error] == :protocol_error
          goaway(frame[:error])
        else
          # HEADERS and PUSH_PROMISE may generate CONTINUATION. Also send
          # RST_STREAM that are not protocol errors
          frames = encode(frame)
          frames.each { |f| emit(:frame, f) }
        end
      end
    end
Send an outgoing frame. DATA frames are subject to connection flow
 control and may be split and / or buffered based on current window size.
 All other frames are sent immediately.

 @note all frames are currently delivered in FIFO order.
 @param frame [Hash]