 
   def handle_info({:tcp, socket, data}, %{socket: socket} = state) do
     :ok = :inet.setopts(socket, active: :once)
-    state = new_data(state, state.tail <> data)
+    state = new_data(state, data)
     {:noreply, state}
   end
 


  defstruct [
    opts: nil,
    tail: "",
    socket: nil,
    recipients: HashDict.new,
    monitors: HashDict.new,
    queue: :queue.new,
    clients_to_notify_of_reconnection: [],
    current_backoff: nil,
  ]

  end

  defp new_data(state, <<>>) do
    state
  end

  defp new_data(state, data) do
    parser = state.continuation || &Protocol.parse/1
    case parser.(data) do
      {:ok, resp, rest} ->
        state
        |> handle_message(resp)
        |> Map.put(:continuation, nil)
        |> new_data(rest)
      {:continuation, continuation} ->
        %{state | continuation: continuation}
    end
  end

