#ifndef __SubscriptionManager_h__
#define __SubscriptionManager_h__

#include "Command.h"
#include "MString.h"
#include "SessionFilter.h"
#include "Subscription.h"
#include "SubscriptionHandler.h"
#include "TCPSession.h"
#include "ZString.h"
#include <vector>

namespace core {

  //*AUTHOR -> Dies when player disconnects
  //*ANYONE -> Does not die when player disconnects
  //*SUBSCRIPTION -> Does not die when player disconnects
  //*OWNER -> Does die and transfers Ownership before he does

  class SubscriptionHandlerFactory;

  class SubscriptionManager : public Command {

  public:
    int add(Subscription &subscription);
    int removeSessionSubscriptions(TCPSession &session);
    int processCommand(coreutils::ZString &request, TCPSession &session) override;
    bool onClearSubscription(coreutils::MString temp, coreutils::MString key);
    SubscriptionHandlerFactory *factory = NULL;

  private:
    Subscription *subscription;
    std::map<coreutils::MString, Subscription *> subscriptions;
    Subscription *newSubscription;
    std::mutex lock;
    coreutils::MString invitee;
     
  };

}

#endif
