From 4cce7b0469c53dcab7d6d402b21100f6542b7164 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Thu, 30 Jan 2014 13:36:30 -0800 Subject: [PATCH] core must keep sink subscriptions even if there are no sources. when sources come online, the connections will be made --- CMakeLists.txt | 2 +- ambd/core.cpp | 9 +++++---- examples/websocketsink2 | 6 +++--- examples/websocketsource2 | 2 +- plugins/websocket/websocketsource.cpp | 2 +- plugins/websocketsink/CMakeLists.txt | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7e20cd..725513d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set (DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PROJECT_NAME} option(qtmainloop "Use QCoreApplication mainloop " OFF) option(websocket_plugin "websocket source and sink plugins" OFF) -option(websocketsink_plugin "old websocket sink plugin" OFF) +option(websocketold_plugin "old websocket sink plugin" OFF) option(tpms_plugin "TPMS plugin " OFF) option(obd2_plugin "OBD-II plugin" OFF) option(database_plugin "Database plugins" OFF) diff --git a/ambd/core.cpp b/ambd/core.cpp index 077c1f8..6175458 100644 --- a/ambd/core.cpp +++ b/ambd/core.cpp @@ -244,7 +244,8 @@ bool Core::subscribeToProperty(VehicleProperty::Property property, AbstractSink* auto itr = mMasterPropertyList.begin(); while(itr != mMasterPropertyList.end()) { - if(itr->second == property) { + VehicleProperty::Property prop = itr->second; + if(prop == property) { AbstractSource* src = itr->first; src->subscribeToPropertyChanges(property); // Move to next source. It will skip all the remaining properties in this source. @@ -256,8 +257,8 @@ bool Core::subscribeToProperty(VehicleProperty::Property property, AbstractSink* } } - if(subscribed) - propertySinkMap[property].emplace(sink, std::string("")); + //if(subscribed) + propertySinkMap[property].emplace(sink, std::string("")); return subscribed; } @@ -368,7 +369,7 @@ void Core::handleAddSupported(const PropertyList& added, AbstractSource* source) // Subscribe to property in a new source if such property was subscribed. This catches newly supported properties in the process. // // TODO: is this sufficient to: - /// Iterate through subscribed properties and resubscribe. This catches newly supported properties in the process. + // Iterate through subscribed properties and resubscribe. This catches newly supported properties in the process. // which was originally located at the end of the setSupported and updateSupported functions? I think it is sufficient. if( propertySinkMap.find(property) != propertySinkMap.end()){ source->subscribeToPropertyChanges(property); diff --git a/examples/websocketsink2 b/examples/websocketsink2 index 2ecebd4..bff577d 100644 --- a/examples/websocketsink2 +++ b/examples/websocketsink2 @@ -3,14 +3,14 @@ { "name" : "ExampleSouce", "path" : "/usr/lib/automotive-message-broker/examplesourceplugin.so", - "delay" : "6" + "delay" : "1000" } ], "sinks": [ { "name" : "WebSocketSink", - "path" : "/usr/lib/automotive-message-broker/websocketsinkplugin.so", - "interface" : "lo", + "path" : "/usr/lib/automotive-message-broker/websocketsink.so", + "interface" : "eth1", "ssl" : "false", "port" : "23000", "binaryProtocol" : "false" diff --git a/examples/websocketsource2 b/examples/websocketsource2 index 0c45aaa..cad1a44 100644 --- a/examples/websocketsource2 +++ b/examples/websocketsource2 @@ -5,7 +5,7 @@ "path" : "/usr/lib/automotive-message-broker/websocketsource.so", "port" : "23000", "ssl" : "false", - "ip" : "127.0.0.1", + "ip" : "192.168.1.40", "binaryProtocol" : "false" } ], diff --git a/plugins/websocket/websocketsource.cpp b/plugins/websocket/websocketsource.cpp index 5ac26d3..615af3c 100644 --- a/plugins/websocket/websocketsource.cpp +++ b/plugins/websocket/websocketsource.cpp @@ -463,7 +463,7 @@ static int callback_http_only(libwebsocket_context *context,struct libwebsocket } void WebSocketSource::setSupported(PropertyList list) { - DebugOut() <<__SMALLFILE__ << ":" << __LINE__ <<"SET SUPPORTED"<updateSupported(list,PropertyList(),this); } diff --git a/plugins/websocketsink/CMakeLists.txt b/plugins/websocketsink/CMakeLists.txt index 998340c..f911069 100644 --- a/plugins/websocketsink/CMakeLists.txt +++ b/plugins/websocketsink/CMakeLists.txt @@ -1,4 +1,4 @@ -if(websocketsink_plugin) +if(websocketold_plugin) include(CheckIncludeFiles) include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs}) @@ -13,4 +13,4 @@ target_link_libraries(websocketsinkplugin amb ${websockets_LIBRARIES} -L${CMAKE_ install(TARGETS websocketsinkplugin LIBRARY DESTINATION lib${LIB_SUFFIX}/automotive-message-broker) -endif(websocketsink_plugin) +endif(websocketold_plugin) -- 2.7.4