}
try
{
+ ar(cereal::make_nvp(OC::Key::SERVERIDKEY, m_serverId));
+ m_loaded=true;
+ }
+ catch(cereal::Exception&)
+ {
+ ar.setNextName(nullptr);
+ }
+ try
+ {
ar(cereal::make_nvp(OC::Key::PROPERTYKEY, m_props));
m_loaded=true;
}
std::string m_uri;
+ std::string m_serverId;
bool m_loaded;
ListenResourcePropertiesContainer m_props;
}
public:
ListenOCContainer(std::weak_ptr<IClientWrapper> cw, const OCDevAddr& address,
- std::stringstream& json):
- m_clientWrapper(cw), m_address(address)
+ OCConnectivityType connectivityType, std::stringstream& json):
+ m_clientWrapper(cw), m_address(address), m_connectivityType(connectivityType)
{
LoadFromJson(json);
}
private:
std::string ConvertOCAddrToString(OCSecureType sec, int secureport)
{
- char stringAddress[DEV_ADDR_SIZE_MAX];
uint16_t port;
-
- ostringstream os;
+ std::ostringstream os;
if(sec== OCSecureType::IPv4)
{
throw ResourceInitException(false, false, false, false, false, true);
}
- if(0== OCDevAddrToString(&m_address, stringAddress))
- {
- // nothing to do, successful case.
- }
- else
+ uint8_t a;
+ uint8_t b;
+ uint8_t c;
+ uint8_t d;
+ if(OCDevAddrToIPv4Addr(&m_address, &a, &b, &c, &d) != 0)
{
oclog() << "ConvertOCAddrToString(): Invalid Ip"
- << std::flush;
+ << std::flush;
throw ResourceInitException(false, false, false, false, false, true);
}
- os<<stringAddress;
+ os<<static_cast<int>(a)<<"."<<static_cast<int>(b)
+ <<"."<<static_cast<int>(c)<<"."<<static_cast<int>(d);
if(sec == OCSecureType::IPv4Secure && secureport>0 && secureport<=65535)
{
else
{
oclog() << "ConvertOCAddrToString() : Invalid Port"
- <<std::flush;
+ <<std::flush;
throw ResourceInitException(false, false, false, false, true, false);
}
m_resources.push_back(std::shared_ptr<OCResource>(
new OCResource(m_clientWrapper,
ConvertOCAddrToString(res.secureType(),res.port()),
- res.m_uri, res.observable(), res.resourceTypes(),
- res.interfaces())));
+ res.m_uri, res.m_serverId, m_connectivityType, res.observable(),
+ res.resourceTypes(), res.interfaces())));
}
}
std::vector<std::shared_ptr<OC::OCResource>> m_resources;
std::weak_ptr<IClientWrapper> m_clientWrapper;
OCDevAddr m_address;
+ OCConnectivityType m_connectivityType;
};
}
+