anchor.diff:      end.
   
   push_to_session(Packet = #packet{qos =?QOS_0},SO) ->
  -    Pub = to_publish(Packet,undefined,false),
  +    Pub = to_publish(Packet),
       {ToSend,SO1} = pull(SO),
       {[Pub|ToSend],SO1};
   
  
positive.code: %% - user orddict ond ordsets to store packets and their states
  %% - use sequentially assigned PSeqs that map to and from PacketIds
  dict_to_pub_packets(Dict) ->
      [to_publish(CTRPacket,PSeq,true) || {PSeq,CTRPacket}  <- orddict:to_list(Dict)].
  
  set_to_pubrel_packets(Rec) ->
      [to_pubrel(PSeq) || {PSeq,PSeq}  <- ordsets:to_list(Rec)].
  
  to_publish(#packet{topic = Topic,
                     content = Content,
                     retain = Retain,
                     qos = QoS},PSeq,Dup) ->
      #'PUBLISH'{content = Content,
                 packet_id = maybe_get_packet_id(PSeq),
                 qos = QoS,
                 topic = Topic,
                 dup = Dup,
  
negative.code: %% @end
  get_ack_seq(PacketId,PSeq) -> ((PSeq band 16#ffff) bxor PSeq) bor PacketId.
  
  %% @doc
  %% Maps a potentially large Sequence number to a PacketId
  %% @end
  maybe_get_packet_id(undefined) -> undefined;
  maybe_get_packet_id(PSeq) -> get_packet_id(PSeq).
  
  get_packet_id(PSeq) -> PSeq band 16#ffff.
  
  new() -> new(?DEFAULT_MAX_WINDOW).
  