Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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 // linux

close_eventbus();
return 0;
}

void function(String *msg){
printf("%s",*msg);
i++;
}

```