Added comments to demo code.

This commit is contained in:
Nicolás Ortega Froysa 2017-11-20 13:55:06 +01:00
parent c8964ad81a
commit 5b5660e5c4
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF

View File

@ -45,12 +45,14 @@ int main(int argc, char *argv[]) {
connect_port = atoi(argv[3]);
}
// initialize NeoComm framework
if(!NeoComm_init(port))
{
fprintf(stderr, "%s\n", NeoComm_get_last_error());
return 1;
}
// connect to an individual node
if(connect_address)
NeoComm_connect(connect_address, connect_port);
@ -63,6 +65,7 @@ int main(int argc, char *argv[]) {
run = 0;
else if(strcmp(in, "/stats") == 0)
{
// get statistics
struct stats statistics = NeoComm_get_node_stats();
printf("Good: %u\nDubious: %u\nCached: %u\nIncoming: %u\nTotal: %u\n",
statistics.good,
@ -76,6 +79,7 @@ int main(int argc, char *argv[]) {
const char *chan = strchr(in, '#');
if(!chan)
puts("No channel name detected. Channel names start with `#'.");
// join a channel
NeoComm_join_channel(chan);
}
else if(strstr(in, "/leave") == in)
@ -83,6 +87,7 @@ int main(int argc, char *argv[]) {
const char *chan = strchr(in, '#');
if(!chan)
puts("No channel name detected. Channel names start with `#'.");
// leave a channel
if(!NeoComm_leave_channel(chan))
printf("%s\n", NeoComm_get_last_error());
}
@ -90,6 +95,7 @@ int main(int argc, char *argv[]) {
print_help();
}
// deinitialize the network
NeoComm_deinit();
return 0;
}