mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-14 06:15:57 +00:00
f6121c10f0
- re-enable Nim's cache globally - add a new "nimcache" subdir for the libraries - make sure Go doesn't try to link libnimbus.a in the dynamically linked wrapper example - always delete the static archive before recreating it - rename wrapper.nim/.h to libnimbus.nim/.h - better hygiene in libnimbus.h (include guards and C++ support) - remove MainnetBootnodes copy, since we do include "config.nim" after all
45 lines
908 B
C
45 lines
908 B
C
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <time.h>
|
|
|
|
#include "libnimbus.h"
|
|
|
|
void NimMain();
|
|
|
|
void print_msg(received_message* msg) {
|
|
printf("Got message! %ld\n", msg->decodedLen);
|
|
}
|
|
|
|
const char* channel = "status-test-c";
|
|
|
|
const char* msg = "testing message";
|
|
|
|
int main(int argc, char* argv[]) {
|
|
time_t lastmsg;
|
|
|
|
NimMain();
|
|
nimbus_start(30303);
|
|
|
|
nimbus_subscribe(channel, print_msg);
|
|
|
|
lastmsg = time(NULL);
|
|
|
|
while(1) {
|
|
usleep(1);
|
|
|
|
if (lastmsg + 1 <= time(NULL)) {
|
|
lastmsg = time(NULL);
|
|
char buf[4096];
|
|
snprintf(buf, 4095,
|
|
"[\"~#c4\",[\"%s\",\"text/plain\",\"~:public-group-user-message\",%ld,%ld,[\"^ \",\"~:chat-id\",\"%s\",\"~:text\",\"%s\"]]]",
|
|
msg, lastmsg * 1000 * 100, lastmsg * 1000, channel, msg);
|
|
|
|
printf("Posting %s\n", buf);
|
|
nimbus_post(channel, buf);
|
|
}
|
|
nimbus_poll();
|
|
}
|
|
}
|