diff --git a/README.md b/README.md index 10d80b7..86cafca 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ What follows is a list roadmap of features and the (approximate) versions in whi - v1.0-alpha: - [ ] Node connectivity - [ ] Messages properly sent and received - - v1.0-beta: - [ ] Channel functionality + - v1.0-beta: - [ ] Message encryption - [ ] P2P Private messages - v1.0: diff --git a/include/neocomm.h b/include/neocomm.h index e4fe288..594368f 100644 --- a/include/neocomm.h +++ b/include/neocomm.h @@ -23,11 +23,12 @@ extern "C" { #endif /** - * @brief Initialize a local DHT node. + * @brief Initialize a local DHT node. If port is 0 then the default port + * number will be used. * * @param port The port for the node to listen on. */ -void NeoComm_init(const unsigned short port); +void NeoComm_init(unsigned short port); /** * @brief Deinitialize the local node. @@ -48,7 +49,7 @@ void NeoComm_connect(const char *address, const unsigned short port); * @param node_file Path to the node list file. * * @return 1 upon success, 0 upon failure. Use NeoComm_get_last_error for a - * text version of the error. + * text description of the error. */ int NeoComm_import_nodes(const char *node_file); @@ -58,10 +59,20 @@ int NeoComm_import_nodes(const char *node_file); * @param node_file path to node list file. * * @return 1 upon success, 0 upon failure. Use NeoComm_get_last_error for a - * text version of the error. + * text description of the error. */ int NeoComm_export_nodes(const char *node_file); +/** + * @brief Join a channel. + * + * @param channel_name Name of the channel. + * + * @return 1 upon success, 0 upon failure. Use NeoComm_get_last_error for a + * text description of the error. + */ +int NeoComm_join_channel(const char *channel_name); + /** * @brief Get the last error that occurred in text. * diff --git a/src/node.cpp b/src/node.cpp index d5e35b6..ea1323a 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -24,9 +24,13 @@ #include #include +#define DEFAULT_PORT 1335 + static dht::DhtRunner node; -void NeoComm_init(const unsigned short port) { +void NeoComm_init(unsigned short port) { + if(port == 0) + port = DEFAULT_PORT; node.run(port, dht::crypto::generateIdentity(), true); }