1
0
Fork 0
mirror of https://github.com/besterprotocol/besterd synced 2023-12-13 21:00:32 +01:00

Add scope check

This commit is contained in:
Tristan B. Kildaire 2020-04-16 22:56:06 +02:00
parent 8b82b975d8
commit 18f11b2ba4

View file

@ -6,6 +6,7 @@ import std.socket : Socket, AddressFamily, SocketType, ProtocolType, parseAddres
import core.thread : Thread;
import std.stdio : writeln;
import std.json : JSONValue, parseJSON, JSONException, JSONType;
import std.string;
public class BesterServer
{
@ -144,6 +145,42 @@ private class BesterConnection : Thread
{
/* TODO: Add further checks here */
/* The header must contain a scope block */
JSONValue scopeBlock;
/* TODO: Add bounds check */
scopeBlock = besterHeader["scope"];
/* Make sure the type of the JSON value is string */
if(scopeBlock.type == JSONType.string)
{
/* Get the scope */
string scopeString = scopeBlock.str;
debugPrint("Scope selected: " ~ scopeString);
/* If the message is for client<->server */
if(cmp(scopeString, "client"))
{
}
/* If the message is for server<->server */
else if(cmp(scopeString, "server"))
{
}
else
{
}
}
else
{
/* TODO: Handle error */
debugPrint("Scope block JSON value not a string");
}
/* The header must contain a authentication JSON object */
JSONValue authenticationBlock;