
#ifndef _RTP808SERVICE_H_
#define _RTP808SERVICE_H_

#include "MFSPublic.h"
#include "3rd/uvw.hpp"
#include "BaseService.h"
#include "Rtp808Protocol.h"

namespace mfs
{
    
class Rtp808Service:public BaseService
{
private:
    bool _isYuebiao = false;                                                    // 是否粤标
    std::map<std::string, std::shared_ptr<Rtp808Protocol>> _connectionClientMap;

    Rtp808Service(const std::string& name, int port, std::shared_ptr<uvw::Loop> loop):BaseService(name,port,loop){}
public:
    static Rtp808Service* Instance(int port);
    static Rtp808Service* SetupOnce(std::string& sername, int port, std::shared_ptr<uvw::Loop> loop);

    
    virtual void Init()
    {
        BaseService::Init([this](std::shared_ptr<uvw::Loop> loop, std::shared_ptr<uvw::TCPHandle> client,const std::string& name){
		    auto pclient = new Rtp808Protocol(loop, client, name);
            pclient->isYuebiao(_isYuebiao);
            return pclient;
	    });
    }

    // void CheckAllTimeout();

    std::shared_ptr<Rtp808Protocol> GetRtpServiceByUrl(const std::string& url);
    
    bool isYuebiao(){return _isYuebiao;}
    void isYuebiao(bool v){_isYuebiao=v;}
protected:
    // 新的连接
    virtual void OnListen(std::shared_ptr<BaseProtocol> client) override;
};

}




#endif // _RTP808SERVICE_H_