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

    Logger.info "AmpqOne Server: Header sucessfully exchanged. Wait for Open-Frame."
    %__MODULE__{state | state: :hdr_exch}
  end
  def connection(:hdr_exch, %Frame.Open{} = f, state) do
    Logger.info "Client: sending open frame"
    :ok = AmqpOne.Transport.Socket.send(state.socket, encode_frame(0, f))
    %__MODULE__{state | state: :open_sent}
  end
  # channel must be zero for opening a connection
  def connection(:hdr_exch, {:tcp, {0, %Frame.Open{} = f}}, state) do
    Logger.info "Server: Received an  an open frame: #{inspect f}"
    %__MODULE__{state | state: :open_rcvd, connection_parameters: f}
  end
  def connection(:open_rcvd, %Frame.Open{}  = f, state) do
    Logger.info "Got an internal open frame"
    :ok = AmqpOne.Transport.Socket.send(state.socket, encode_frame(0, f))
    %__MODULE__{state | state: :opened}
  end
  # channel must be zero for opening a connection
  def connection(:open_sent, {:tcp, {0, %Frame.Open{} = f}}, state) do
    Logger.info "Received an open frame: #{inspect f}"
    %__MODULE__{state | state: :opened, connection_parameters: f}
  end
  def connection(:open_sent, %Frame.Close{} = f, state) do
    Logger.info "Got an internal close frame: #{inspect f}"
    :ok = AmqpOne.Transport.Socket.send(state.socket, encode_frame(0, f))
    %__MODULE__{state | state: :close_pipe}
  end
  def connection(:opened, %Frame.Close{} = f, state) do
    Logger.info "Got an internal close frame: #{inspect f}"
    :ok = AmqpOne.Transport.Socket.send(state.socket, encode_frame(0, f))
    %__MODULE__{state | state: :close_sent}
  end
  # channel must be zero for closing a connection
  def connection(:open_sent, {:tcp, {0, %Frame.Close{} = f}}, state) do
    Logger.info "Got an close frame: #{inspect f}"
    %__MODULE__{state | state: :close_rcvd}
  end

    Socket.set_active_once(state.socket)
    put_in(state, :state, :hdr_rcvd)
  end
  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}
