public void CommandSubscribe() {
Table replyTable = Table.LoadTable(client, tableName);
Console.WriteLine("Listening to the events continuously.");
Int64 last_key = 0;
while (true) {
var scan_filter = new ScanFilter();
if (last_key > 0) {
scan_filter.AddCondition("K", ScanOperator.GreaterThan, last_key);
}
Search search = replyTable.Scan(scan_filter);
List<Document> documentList = new List<Document>();
do {
documentList = search.GetNextSet();
foreach (var document in documentList) {
Console.WriteLine("{0} : {1}", document["K"], document["V"]);
Int64 current_key = Int64.Parse(document["K"].AsString());
if (!(current_key > last_key)) {
Console.WriteLine("ERROR: {0} should be > {1}.", current_key, last_key);
}
else {
last_key = current_key;
}
}
} while (!search.IsDone);
// TODO(dkorolev): Do something smarter here, and wrap the whole thing into an IObservable<>.
System.Threading.Thread.Sleep(50);
}
}