- template <class Archive>
- void serialize(Archive& ar)
- {
- try
- {
- ar(cereal::make_nvp(OC::Key::URIKEY, m_uri));
- m_loaded=true;
- }
- catch(cereal::Exception&)
- {
- ar.setNextName(nullptr);
- }
- 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;
- }
- catch(cereal::Exception&)
- {
- ar.setNextName(nullptr);
+ if (payload->baseURI)
+ {
+ OCDevAddr rdPubAddr = currentDevAddr;
+
+ std::string baseURI = std::string(payload->baseURI);
+ size_t len = baseURI.length();
+ int addressLen = baseURI.find_first_of(":");
+ std::string ipaddress = baseURI.substr(0, addressLen);
+ int port = atoi(baseURI.substr(addressLen + 1, len).c_str());
+ OICStrcpy(rdPubAddr.addr, addressLen + 1, ipaddress.c_str());
+ rdPubAddr.port = port;
+ m_resources.push_back(std::shared_ptr<OC::OCResource>(
+ new OC::OCResource(cw, rdPubAddr,
+ std::string(res->uri),
+ std::string(payload->sid),
+ res->bitmap,
+ StringLLToVector(res->types),
+ StringLLToVector(res->interfaces),
+ deviceName
+ )));
+ }
+ else
+ {
+ m_resources.push_back(std::shared_ptr<OC::OCResource>(
+ new OC::OCResource(cw, currentDevAddr,
+ std::string(res->uri),
+ std::string(payload->sid),
+ res->bitmap,
+ StringLLToVector(res->types),
+ StringLLToVector(res->interfaces),
+ deviceName
+ )));
+
+#ifdef TCP_ADAPTER
+ if (res->tcpPort != 0)
+ {
+ OCDevAddr tcpDevAddr = currentDevAddr;
+ tcpDevAddr.port = res->tcpPort;
+ tcpDevAddr.adapter = OC_ADAPTER_TCP;
+ m_resources.push_back(std::shared_ptr<OC::OCResource>(
+ new OC::OCResource(cw, tcpDevAddr,
+ std::string(res->uri),
+ std::string(payload->sid),
+ res->bitmap,
+ StringLLToVector(res->types),
+ StringLLToVector(res->interfaces),
+ deviceName
+ )));
+ }
+#endif
+ }
+ res = res->next;
+ }
+ payload = payload->next;