     Socket.set_active_once(state.socket)
     put_in(state, :state, :hdr_rcvd)
   end
-  def connection(:hdr_sent, %Frame.Open{} = f, state) do
+  def connection(:hdr_sent, f = %Frame.Open{}, state) do
     # we are sending an open directly after the hdr: pipelining!
     AmqpOne.Transport.Socket.send(state.socket, encode_frame(0, f))
     %__MODULE__{state | state: :open_pipe}

    Logger.error "We should send this frame to someone else"
    state
  end
  def connection(:close_sent, {:tcp, {0, %Frame.Close{} = f}}, state) do
    AmqpOne.Transport.Socket.close(state.socket)
    %__MODULE__{state | state: :end}
  end
  def connection(:close_rcvd, %Frame.Close{}= f, state) do
    :ok = AmqpOne.Transport.Socket.send(state.socket, encode_frame(0, f))
    AmqpOne.Transport.Socket.close(state.socket)
    %__MODULE__{state | state: :end}
  end
  def conncetion(:open_pipe, %Frame.Close{} = f, state) do
    :ok = AmqpOne.Transport.Socket.send(state.socket, encode_frame(0, f))
    %__MODULE__{state | state: :oc_pipe}
  end
  def conncetion(:open_pipe, @amqp_header, state) do
    %__MODULE__{state | state: :open_sent}
  end
  def conncetion(:close_pipe, {:tcp, {0, %Frame.Open{} = f}}, state) do
    Logger.info "Got an open frame: #{inspect f}"
    %__MODULE__{state | state: :close_sent, connection_parameters: f}
  end

        value = AmqpOne.Encoding.decode_bin(frame)
        {channel, value}
      any_type ->
        Logger.error "Unknown frame type #{any_type}"
        ^any_type = @amqp_frame
      end
  end
