anchor.diff:  -record(state, {channels, iorio}).
   
   init(_Transport, Req, Opts, _Active) ->
  -    io:format("listen init ~p~n", [Opts]),
  +    lager:info("listener init ~p~n", [Opts]),
       {ok, Req, #state{channels=[], iorio=iorio}}.
   
   get_channel_args(Msg) ->
  
positive.code:                         IsSubscribed = contains(Key, Channels),
                          if
                              IsSubscribed ->
                                 {encode_error(<<"already subscribed">>, Id), State};
  
                              true ->
                                  Iorio:subscribe(Bucket, Stream, self()),
                                  NewChannels = [Key|Channels],
                                  io:format("old ~p~nnew ~p~n", [Channels, NewChannels]),
                                  State1 = State#state{channels=NewChannels},
                                  {encode_ok(Id), State1}
                          end
  
negative.code:                         IsSubscribed = contains(Key, Channels),
                          if
                              IsSubscribed ->
                                  lager:info("unsubscribing ~s/~s~n", [Bucket, Stream]),
                                  Iorio:unsubscribe(Bucket, Stream, self()),
                                  NewChannels = remove(Key, Channels),
                                  State1 = State#state{channels=NewChannels},
                                  {encode_ok(Id), State1};
  
                              true ->
                                  lager:warning("not subscribed ~s/~s~n", [Bucket, Stream]),
                                  {encode_error(<<"not subscribed">>, Id), State}
  
                          end
                  end, Msg, Id, Req, State).
  
  encode_error(Reason, Id) ->
      lager:warning("error ~s ~p~n", [Reason, Id]),
      IdBin = integer_to_binary(Id),
      <<"{\"ok\":false,\"id\":", IdBin, ",\"reason\":\"", Reason/binary, "\"}">>.
  
  stream(Data, Req, State) ->
      lager:debug("msg received ~p~n", [Data]),
      Msg = jsx:decode(Data),
      Id = proplists:get_value(<<"id">>, Msg, 0),
      case proplists:get_value(<<"cmd">>, Msg) of
  