https://github.com/nariakiiwatani/ofxMessageHub
Routing, Recording and Playing any kind of messages.
https://github.com/nariakiiwatani/ofxMessageHub
Last synced: 4 months ago
JSON representation
Routing, Recording and Playing any kind of messages.
- Host: GitHub
- URL: https://github.com/nariakiiwatani/ofxMessageHub
- Owner: nariakiiwatani
- License: mit
- Created: 2016-09-04T14:07:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-08T13:06:03.000Z (over 8 years ago)
- Last Synced: 2024-08-01T13:25:14.456Z (7 months ago)
- Language: C++
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# ofxMessageHub
Routing, Recording and Playing any kind of messages.
## How to use
Probably you want to use the addon to Route, Record or Play __ofxOscMessage__s in most cases.
If so, See [for ofxOscMessage](#forosc)### Server and Client
```
// client1 gets messages from both servers
// client2 gets only from server2
using namespace ofx::messagehub;
class Message; // any MessageTypestd::shared_ptr> server1, server2;
std::shared_ptr> client1, client2;
client1->connect(server1);
client1->connect(server2);
client2->connect(server2);
```### Bus
```
// bus works like a server group
// client receives from all servers through the bus
using namespace ofx::messagehub;
class Message; // any MessageTypestd::shared_ptr> server1, server2, server3;
std::shared_ptr> client;
std::shared_ptr> bus;
bus->connect(server1);
bus->connect(server2);
bus->connect(server3);
client->connect(sub);```
Bus also can convert MessageType by giving template argument.
ex. `ofx::messagehub::Bus`
You may need to complete your converter(third argument).
If developed a cool cenverter, please PR.### Player
```
using namespace ofx::messagehub;
class Message; // any MessageTypeclass MyPlayer : public Player
{
protected:
std::deque getMessagesInRange(const typename Timer::CounterType &lower, const typename Timer::CounterType &upper) {
std::deque ret;
// let's make deque made from Messages in range [lower,upper)
return ret;
}
};```
#### BufferPlayer
If you want to store Messages in Buffer, it's the better way to use `BufferPlayer`.
All you need to do is declare your class that extends BufferPlayer and store something to `buffer_`.
If the messages are in a file in certain format, it's good way to add `load()` function to your class.### Recorder
```
using namespace ofx::messagehub;
class Message; // any MessageTypeclass MyRecorder : public Recorder
{
public:
void record(const typename Timer::CounterType &time, const Message &msg) {
// store time and message wherever you want to.
}
};
```#### BufferRecorder
In BufferRecorder, recorded messages are automatically stored in `buffer_`.
You may want to implement something like `save()` function to save the buffer to a file.This addon includes some classes for ofxOsc for instant use.(and maybe that's enough)
- Receiver : Receives messages sent to binded port.
- Sender : Sends messages to certain host/port.
- JsonRecorder : Records received ofxOscMessage(s) to a file in JSON format.
- JsonPlayer : Playbacks recorded JSON file as ofxOscMessage(s).
- Bus : Relays messages.