Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nariakiiwatani/ofxMessageHub

Routing, Recording and Playing any kind of messages.
https://github.com/nariakiiwatani/ofxMessageHub

Last synced: about 2 months ago
JSON representation

Routing, Recording and Playing any kind of messages.

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 MessageType

std::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 MessageType

std::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 MessageType

class 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 MessageType

class 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.

## for ofxOscMessage

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.