Added `awaitNotification()` function to fetch notification (the first one in the queue)

This commit is contained in:
Tristan B. Kildaire 2020-10-17 12:20:48 +02:00
parent 76fdd56eea
commit 8a67535c85
1 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@ module libdnet.dclient;
import tristanable.manager : Manager;
import tristanable.queue : Queue;
import tristanable.encoding : DataMessage;
import tristanable.queueitem : QueueItem;
import std.socket;
import std.stdio;
import std.conv : to;
@ -62,7 +63,22 @@ public final class DClient
manager.addQueue(notificationQueue);
}
/**
* Receives the head of the notification queue
*/
private byte[] awaitNotification()
{
/* The received notification */
byte[] notification;
/* Await the notification */
QueueItem queueItem = notificationQueue.dequeue();
/* Grab the notification's data */
notification = queueItem.getData();
return notification;
}
/**
* Authenticates as a client with the server