-#ifdef CA_INT
- ListenOCContainer(std::weak_ptr<IClientWrapper> cw, const OCDevAddr& address,
- OCConnectivityType connectivityType, std::stringstream& json):
- m_clientWrapper(cw), m_address(address), m_connectivityType(connectivityType)
-#else
- ListenOCContainer(std::weak_ptr<IClientWrapper> cw, const OCDevAddr& address,
- std::stringstream& json):
- m_clientWrapper(cw), m_address(address)
-#endif
- {
- LoadFromJson(json);
- }
-
- const std::vector<std::shared_ptr<OCResource>>& Resources() const
- {
- return m_resources;
- }
-
- private:
- std::string ConvertOCAddrToString(OCSecureType sec, int secureport)
- {
- char stringAddress[DEV_ADDR_SIZE_MAX];
- uint16_t port;
-
- ostringstream os;
-
- if(sec== OCSecureType::IPv4)
- {
- os<<"coap://";
- }
- else if(sec == OCSecureType::IPv4Secure)
- {
- os<<"coaps://";
- }
- else
- {
- oclog() << "ConvertOCAddrToString(): invalid SecureType"<<std::flush;
- throw ResourceInitException(false, false, false, false, false, true);
- }
-
- if(0== OCDevAddrToString(&m_address, stringAddress))
- {
- // nothing to do, successful case.
- }
- else
- {
- oclog() << "ConvertOCAddrToString(): Invalid Ip"
- << std::flush;
- throw ResourceInitException(false, false, false, false, false, true);
- }
-
- os<<stringAddress;
-
- if(sec == OCSecureType::IPv4Secure && secureport>0 && secureport<=65535)
- {
- port = static_cast<uint16_t>(secureport);
- }
- else if(sec == OCSecureType::IPv4 && 0==OCDevAddrToPort(&m_address, &port))
- {
- // nothing to do, this is a successful case
- }
- else
- {
- oclog() << "ConvertOCAddrToString() : Invalid Port"
- <<std::flush;
- throw ResourceInitException(false, false, false, false, true, false);
- }
-
- os <<":"<< static_cast<int>(port);
-
- return os.str();
- }
-
- void LoadFromJson(std::stringstream& json)