anchor.diff:      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).
  -
   maybe_persist(S) ->
       %% @todo: handle persistence
       S.
  
positive.code:     send_to_client(Sender, Packet);
  
  send_to_client(Sender, Packet) ->
      mqtt_sender:send_packet(Sender, Packet).
negative.code: -spec(terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()),
      State :: #state{}) -> term()).
  
  terminate(_Reason,S) ->
      cleanup(S).
  
  %%--------------------------------------------------------------------
  %% @private
  