Connect may give error.
This commit is contained in:
20
src/node.cpp
20
src/node.cpp
@ -18,6 +18,7 @@
|
||||
|
||||
#include "neocomm.h"
|
||||
|
||||
#include "globals.hpp"
|
||||
#include "error.hpp"
|
||||
|
||||
#include <opendht.h>
|
||||
@ -26,7 +27,7 @@
|
||||
|
||||
#define DEFAULT_PORT 1335
|
||||
|
||||
static dht::DhtRunner node;
|
||||
dht::DhtRunner node;
|
||||
|
||||
void NeoComm_init(unsigned short port) {
|
||||
if(port == 0)
|
||||
@ -38,13 +39,24 @@ void NeoComm_deinit() {
|
||||
node.join();
|
||||
}
|
||||
|
||||
void NeoComm_connect(const char *address, const unsigned short port) {
|
||||
int NeoComm_connect(const char *address, const unsigned short port) {
|
||||
if(not node.isRunning())
|
||||
{
|
||||
add_error("NeoComm must be initialized.");
|
||||
return 0;
|
||||
}
|
||||
node.bootstrap(address, std::to_string(port));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// NOTICE: When the new OpenDHT release comes out this code should work.
|
||||
// Meanwhile just keep it commented out.
|
||||
/*int NeoComm_import_nodes(const char *node_file) {
|
||||
if(not node.isRunning())
|
||||
{
|
||||
add_error("NeoComm must be initialized.");
|
||||
return 0;
|
||||
}
|
||||
msgpack::unpacker upak;
|
||||
{
|
||||
std::ifstream import_file(node_file, std::ios::binary bitor
|
||||
@ -72,6 +84,10 @@ void NeoComm_connect(const char *address, const unsigned short port) {
|
||||
}*/
|
||||
|
||||
/*int NeoComm_export_nodes(const char *node_file) {
|
||||
if(not node.isRunning())
|
||||
{
|
||||
add_error("NeoComm must be initialized.");
|
||||
}
|
||||
std::ofstream export_file(node_file, std::ios::binary);
|
||||
if(not export_file.is_open())
|
||||
{
|
||||
|
Reference in New Issue
Block a user