Created
November 11, 2015 04:56
-
-
Save PeterJohnson/ebb35d04ead31b0ca20a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <cstdio> | |
#include <thread> | |
#include "ntcore.h" | |
int main() { | |
nt::StartServer("persistent2.ini", "", 10000); | |
std::this_thread::sleep_for(std::chrono::seconds(1)); | |
nt::DeleteAllEntries(); | |
nt::SetEntryValue("Key", nt::Value::MakeString("Value")); | |
int listener = nt::AddEntryListener( | |
"Key", [](unsigned int uid, llvm::StringRef name, | |
std::shared_ptr<nt::Value> value, unsigned int flags) { | |
printf("%d: %s\n", uid, name.data()); | |
}, | |
NT_NOTIFY_NEW | NT_NOTIFY_UPDATE | NT_NOTIFY_IMMEDIATE); | |
nt::SetEntryValue("Key", nt::Value::MakeString("Value2")); | |
std::this_thread::sleep_for(std::chrono::milliseconds(20)); | |
nt::RemoveEntryListener(listener); | |
puts("finished"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment