Skip to content

Commit

Permalink
fixes in example + updated todo
Browse files Browse the repository at this point in the history
  • Loading branch information
cinemast committed Jul 6, 2015
1 parent 1c3a8d8 commit 9861224
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 45 deletions.
4 changes: 1 addition & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Decouple BCServer/Client and HTTPServer/Client from PubsubPeer
Decouple Subscription management from PubsubPeer
Use separate ports for BC/HTTPServer to allow several peers on one host
Implement in memory broadcast + http server connector -> testability
Use interface discovery for automatic IP detection

41 changes: 0 additions & 41 deletions spec

This file was deleted.

34 changes: 34 additions & 0 deletions src/example/humiditysensor.cpp.autosave
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*************************************************************************
* libjson-rpc-cpp
*************************************************************************
* @file humiditysensor.cpp
* @date 6/30/2015
* @author Peter Spiess-Knafl <dev@spiessknafl.at>
* @license See attached LICENSE.txt
************************************************************************/

#include "HumiditySensor.h"
#include "ports.h"
#include <iostream>

using namespace std;

int main()
{
HumiditySensor sensor(PORT_BROADCAST, PORT_HUMIDITYSENSOR);
double humidity = 0.2;
if(!sensor.Start())
{
cerr << "Could not start peer" << endl;
return 1;
}
sensor.autoPublishAll();
while(true)
{
sensor.publishHumidityChanged();
sensor.publishHumidityChanged(humidity+= 0.001);
sleep(3);
}

return 0;
}
6 changes: 6 additions & 0 deletions src/example/monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class Monitor : public AbstractMonitor
{
cout << "Temp: " << temp << " °C" << endl;
}

virtual void shutterChanged(bool open)
{
cout << "Shutter changed: " << open << endl;
}
};

int main (int argc, const char * argv[])
Expand All @@ -44,6 +49,7 @@ int main (int argc, const char * argv[])
return 1;
}

//m.addSubscribeTopic();
m.autoSubscribeAll();

while(1)
Expand Down
2 changes: 1 addition & 1 deletion src/example/peers.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
{
"name": "Monitor",
"subscribe": ["airspeedChanged", "humidityChanged", "tempChanged"]
"subscribe": ["airspeedChanged", "humidityChanged", "tempChanged", "shutterChanged"]
}
]
}
Expand Down

0 comments on commit 9861224

Please sign in to comment.