Skip to content

Instantly share code, notes, and snippets.

@PeterJohnson
Created November 11, 2015 04:56
Show Gist options
  • Save PeterJohnson/ebb35d04ead31b0ca20a to your computer and use it in GitHub Desktop.
Save PeterJohnson/ebb35d04ead31b0ca20a to your computer and use it in GitHub Desktop.
#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