anchor.diff:      %% @todo: handle persistence
       S.
   
  -send_to_client(#state{sender_pid = SenderPid}, Packet) ->
  -    mqtt_sender:send_packet(SenderPid, Packet).+send_to_client(#state{sender = Sender}, Packet) ->
  +    send_to_client(Sender, Packet);
  +
  +send_to_client(Sender, Packet) ->
  +    mqtt_sender:send_packet(Sender, Packet).
positive.code: handle_call({pub_rec,PacketId}, _From,  S = #state{session = SO}) ->
      NewSession =
          case mqtt_session:message_pub_rec(SO,PacketId) of
              {ok,S01} ->   maybe_persist(S01);
              duplicate ->  SO
          end,
      %% ALWAYS respond with PubRel
  
negative.code: %%% Internal functions
  %%%===================================================================
  
  maybe_push_msg(SO,Sender,CTRPacket,Retained,QoS) ->
      case mqtt_session:append_msg(SO,CTRPacket,QoS) of
          duplicate ->             %% do nothing
              {duplicate,SO};
          {ok,SO1,PacketId} ->     %% side effects
              push_msg(SO1,Sender,CTRPacket,Retained,QoS,PacketId),
              {ok,SO1}
      end.
  
  push_msg(SO1,Sender,CTRPacket,Retained,QoS,PacketId) ->
      maybe_persist(SO1),
      Packet = mqtt_session:to_publish(CTRPacket,Retained,QoS,PacketId,false),
      send_to_client(Sender,Packet).
  
  cleanup(#state{session = SO, client_id = ClientId}) ->
      mqtt_reg_repo:unregister(ClientId),
      mqtt_session:cleanup(SO).
  