#ifndef __Subscription_h__
#define __Subscription_h__

#include "SubscriptionHandler.h"
#include "ZString.h"
#include <string>
#include <vector>

namespace core
{

   class TCPSession;

   class Subscription
   {

   public:
      Subscription(std::string id, std::string mode = "*AUTHOR");
      Subscription(std::string id, TCPSession &session, std::string mode);
      Subscription(std::string id, TCPSession &session, std::string mode, std::string handler);
      virtual ~Subscription();

      int subscribe(TCPSession &session);
      int unsubscribe(TCPSession &session);

      virtual int process(coreutils::ZString &request, std::stringstream &out, TCPSession &session);

      virtual int onSubscribe(TCPSession &session);

      int event(std::stringstream &out);

      bool ifSubscriber(TCPSession &session);

      void setHandler(SubscriptionHandler *handler);

      //      int processCommand(coreutils::ZString &request, TCPSession &session) override;

      std::string id;
      std::string mode;
      TCPSession *owner;
      std::string handlers;

      SubscriptionHandler &handler;

      std::vector<TCPSession *> subscribers;
   };
}

#endif
