Message Exchange protocol.
Project description
MsgX: Message eXchange
This repository is MsgX, a message exchange interface to send binary data between languages, e.g., from C++ to Python. This is achived by serialising and deserialising native binary representation from some common interface.
This can be used as a publisher and subscriber model between C++ and Python, and a stateful model in the Jupyter notebook ecosystem that captures the incoming message. It supports asynchronous refresh within the notebook whenever a new message is published from your C++ files, and automatically display them within the notebook. This library also support non-notebook usage where it uses MsgX's native figure display from within your browser.
Requirements
-
zeromq (messaging protocol)
-
capnproto (serialisation of message)
Using the library in your C++ project
You can include the project it as you normally. The following shows a snippet to quickly visualise your code using MsgX without much setup
Quick and dirty out-of-tree build in cmake
In your CMakeLists.txt:
cmake_minimum_required(...)
...
# Add as out-of-tree build (with absolute path & binary directory)
add_subdirectory(
/home/soraxas/git-repo/msgx
msgx
)
find_package( msgx REQUIRED )
...
# link the library to your target
target_link_libraries( ${MY_TARGET} msgx )
Example Usage
Say you have something like this in your ${MY_TARGET}
#include "msgx/message.h"
using namespace msgx::kwargs;
int main(int argc, char const *argv[]) {
msgx::MessageX msg;
std::vector<double> x{5, 2, 0, 4, 4, 6, 7};
std::vector<double> y{1, 2, 3, 2, 3, 4, 5};
msg = msg.Mapping("xs"_kw = x, "ys"_kw = y);
msg.send();
}
From python:
>>> from msgx import spin_default
>>> spin_default()
# msg.send(); in c++
{'ys': array([1., 2., 3., 2., 3., 4., 5.]), 'xs': array([5., 2., 0., 4., 4., 6., 7.])}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file msgx-1.0.2.tar.gz
.
File metadata
- Download URL: msgx-1.0.2.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea3721f694a931c717209b04bbc5efb7bbf2e0cf0df4c85abcb026612d67f738 |
|
MD5 | 235f318b8120526e3ac49932e9153cba |
|
BLAKE2b-256 | 58283291c4714b34a3a8a63570d460b30e74c46f9e303b3a5ab35f47a1199910 |
File details
Details for the file msgx-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: msgx-1.0.2-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4124b235ab690ff404751068ed535f4aedc14cf4dafffea28636f8a0691738f7 |
|
MD5 | 1e6996013dd90e89dae2def70d07b53a |
|
BLAKE2b-256 | 663a589b99f973775fc95244fac05c5c5e6fd898f2fe0b2b782e681ce307a516 |