anchor.diff:  do_rpc(S0, Req, Ref, From) ->
       #state{ id_counter = Id,
               rpcs = RPC0 } = S0,
  -    RPC1 = gb_trees:insert(Id, {Ref, From}, RPC0),
  +    RPC1 = gb_trees:insert({client, Id}, {Ref, From}, RPC0),
       write(S0, with_id(Id, Req)),
       S0#state{ id_counter = Id + 1, rpcs = RPC1 }.
   
  
positive.code:             #qos{ level = L } ->
                  Qos = #qos{ level = L,
                              message_id = NextId },
                  RPCS1 = gb_trees:insert(NextId, P0, RPCS),
                  {P0#publish{ qos = Qos },
                   S0#state{
                     rpcs = RPCS1,
  
negative.code:     {Id, {suback, QoSes}};
  make_reply(#unsuback{ message_id = Id }) ->
      {Id, unusback}.
  
  do_ack(S, #publish{ qos = QoS }) ->
      case QoS of
          at_most_once ->
              S;
          #qos{ level = at_least_once,
                message_id = Id } ->
              Ack = #puback{ message_id = Id },
              write(S, Ack),
              S;
          #qos{ level = exactly_once,
                message_id = Id } ->
              #state{ rpcs = RPC } = S,
              Ack = #pubrec{ message_id = Id },
              write(S, Ack),
              RPC1 = gb_trees:insert({server, Id}, Ack, RPC),
              S#state{ rpcs = RPC1 }
      end.
  
  %% `recv` is used to synchronously get another frame from the
  %% socket. Once the connection is open, there's no need to do this,
  