anchor.diff:      {noreply, NewState :: #state{}} |
       {noreply, NewState :: #state{}, timeout() | hibernate} |
       {stop, Reason :: term(), NewState :: #state{}}).
  +
  +handle_cast(async_init, S = #state{filter = Filter,repo = Repo}) ->
  +    SubState = Repo:load(Filter),
  +    S1 = recover(S,SubState),
  +    {noreply,S1};
  +
  +handle_cast({request_more,ClientId,FromSeq,WSize}, S) ->
  +    handle_request_for_more(ClientId,FromSeq,WSize,S),
  +    {noreply,S};
  +
  +handle_cast({ack,ClientId,AckSeq}, S) ->
  +    handle_ack(ClientId,AckSeq,S),
  +    {noreply,S};
  +
   handle_cast(_Request, State) ->
       {noreply, State}.
   
  
positive.code:                                     end
                                end,
                      {[],Subs},Subs),
      S1 = S#state{packet_seq = PSeq1,
                   live_subs = Subs1,
                   queue = SQ1},
      send_packet_to_clients(PushTo,Packet,QoS),
      {reply,{ok,PSeq1},S1}.
  
  
  %% @doc
  %% Updates a sub if the new packet sequence is [Last Sent ... Requested] window
  %% @end
  maybe_update_waiting_sub(PSeq,Sub = #sub{requested = Req})
      when PSeq =< Req ->
      Sub1 = Sub#sub{last_sent = PSeq},
      %%Range = {LSent,PSeq},
      %%{ok,Sub1,Range};
      {ok,Sub1};
  
  maybe_update_waiting_sub(_,_) -> ignore.
  
  handle_request_for_more(ClientId,RequestFrom,WSize,S = #state{live_subs = Subs,
                                                                queue = SQ}) ->
      S1 = case dict:find(ClientId,Subs) of
              {ok,Sub = #sub{pid = Pid}} ->
                  PSeq = shared_queue:max_seq(SQ),
                  {ok,Sub1,{From,To}} = packet_range_to_send(PSeq,WSize,Sub),
                  ActualFrom = max(From,shared_queue:min_seq(SQ)),
                  ActualTo = min(To,shared_queue:max_seq(SQ)),
                  Packets = shared_queue:read(ActualFrom,ActualTo,SQ),
                  S2 = S#state{live_subs = dict:update(ClientId,Sub1,Subs)},
                  %%queue = shared_queue:move(ClientId,ActualTo,SQ)},
                  send_packets(Packets,Pid,S2),
                  S2;
              error ->
                  S
           end,
      {ok,{reply,ok},S1}.
  
  handle_ack(ClientId,AckSeq,S = #state{queue = SQ}) ->
  
negative.code: 
  %% API
  -export([start_link/2,
      %% Subs
      subscribe_self/4,
      cancel/3,
      get_live_clients/1,
      %% Packets
      request_more/4,
      ack/3,
      push/3,
      new/1]).
  
  %% gen_server callbacks
  