Add functionality for getting the current network mode (#202)

Use bit flags to indicate a combination of network mode and status.
This commit is contained in:
Sam Carlberg
2017-06-02 20:25:20 -04:00
committed by Peter Johnson
parent 417cf33f90
commit f43675e2bd
10 changed files with 78 additions and 12 deletions

View File

@@ -57,6 +57,15 @@ enum NT_NotifyKind {
NT_NOTIFY_FLAGS = 0x20 /* flags changed */
};
/** Client/server modes */
enum NT_NetworkMode {
NT_NET_MODE_NONE = 0x00, /* not running */
NT_NET_MODE_SERVER = 0x01, /* running in server mode */
NT_NET_MODE_CLIENT = 0x02, /* running in client mode */
NT_NET_MODE_STARTING = 0x04, /* flag for starting (either client or server) */
NT_NET_MODE_FAILURE = 0x08, /* flag for failure (either client or server) */
};
/*
* Structures
*/
@@ -345,6 +354,11 @@ struct NT_Value** NT_UnpackRpcValues(const char* packed, size_t packed_len,
*/
void NT_SetNetworkIdentity(const char* name, size_t name_len);
/**
* Get the current network mode.
*/
unsigned int NT_GetNetworkMode();
/** Start Server
* Starts a server using the specified filename, listening address, and port.
*

View File

@@ -252,6 +252,7 @@ std::vector<std::shared_ptr<Value>> UnpackRpcValues(StringRef packed,
* Client/Server Functions
*/
void SetNetworkIdentity(StringRef name);
unsigned int GetNetworkMode();
void StartServer(StringRef persist_filename, const char* listen_address,
unsigned int port);
void StopServer();