Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaymine/TCP-eventbus-client-C
vertx tcp eventbus client module for C
https://github.com/jaymine/TCP-eventbus-client-C
Last synced: 3 months ago
JSON representation
vertx tcp eventbus client module for C
- Host: GitHub
- URL: https://github.com/jaymine/TCP-eventbus-client-C
- Owner: jaymine
- License: mit
- Created: 2016-07-20T18:34:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-09T16:53:38.000Z (over 8 years ago)
- Last Synced: 2024-04-11T11:35:30.175Z (7 months ago)
- Language: C
- Homepage:
- Size: 55.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- vertx-awesome - C - Event bus client for C99 using the [TCP-based protocol](https://github.com/vert-x3/vertx-tcp-eventbus-bridge). (Vert.x Event Bus Clients)
README
# TCP-eventbus-client-C
This is a TCP eventbus implementation for C clients. The protocol is quite simple:* 4bytes int32 message length (big endian encoding)
* json string
* built-in keys
1) type: (String, required) One of "send", "publish", "register", "unregister".
2) headers: (Object, optional) Headers with JSON format.
3) body: (Object, optional) Message content in JSON format.
4) address: (String, required) Destination address
5) replyAddress: (String, optional) Address for replying to.
- NOTE : Please edit Makefile according to your OS.
example:```c
#include
#include
#include "vertx/vertx.h"
#include "vertx/parson.h"void function(String *msg);
int i=0;int main(){
create_eventbus();
start_eventbus();//register
eventbus_register("pcs.status",function);
eventbus_register("pcs.status.c",function);
//send
eventbus_send("pcs.status","pcs.status","{\"type\":\"Maths\"}","{\"message\":\"i++\"}");
eventbus_send("pcs.status","pcs.status.c","{\"type\":\"Maths\"}","{\"message\":\"i++\"}");#ifdef _WIN32
Sleep(1000);
#endif // _WIN32
#ifdef __unix__
sleep(1);
#endif // linux//unregister
eventbus_unregister("pcs.status.c");
//send
eventbus_publish("pcs.status","{\"type\":\"Maths\"}","{\"message\":\"i++\"}");
eventbus_send("pcs.status","pcs.status.c","{\"type\":\"Maths\"}","{\"message\":\"i++\"}");
#ifdef _WIN32
Sleep(1000);
#endif // _WIN32
#ifdef __unix__
sleep(1);
#endif // linuxclose_eventbus();
return 0;
}void function(String *msg){
printf("%s",*msg);
i++;
}```