Added function 'getConnectionScope' to get the connections scope
This commit is contained in:
parent
d9f0e1fc1b
commit
91bffd61a4
|
@ -638,6 +638,26 @@ public final class BesterConnection : Thread
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Scope getConnectionScope(JSONValue headerBlock)
|
||||||
|
{
|
||||||
|
/* TODO: Type checking and bounds checking */
|
||||||
|
|
||||||
|
/* Get the identification block */
|
||||||
|
JSONValue identifyBlock = headerBlock["identify"];
|
||||||
|
|
||||||
|
/* Check what type of connection this is */
|
||||||
|
if(cmp(headerBlock["identify"]["type"].str(), "client") == 0)
|
||||||
|
{
|
||||||
|
return Scope.CLIENT;
|
||||||
|
}
|
||||||
|
else if(cmp(headerBlock["identify"]["type"].str(), "server") == 0)
|
||||||
|
{
|
||||||
|
return Scope.SERVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scope.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
/* Process the received message */
|
/* Process the received message */
|
||||||
private void processMessage(byte[] messageBuffer)
|
private void processMessage(byte[] messageBuffer)
|
||||||
{
|
{
|
||||||
|
@ -657,6 +677,8 @@ public final class BesterConnection : Thread
|
||||||
/* Get the header */
|
/* Get the header */
|
||||||
JSONValue headerBlock = jsonMessage["header"];
|
JSONValue headerBlock = jsonMessage["header"];
|
||||||
|
|
||||||
|
/* Get the scope of this connection */
|
||||||
|
|
||||||
/* Get the scope of the message */
|
/* Get the scope of the message */
|
||||||
Scope scopeField;
|
Scope scopeField;
|
||||||
if(cmp(headerBlock["scope"].str, "client") == 0)
|
if(cmp(headerBlock["scope"].str, "client") == 0)
|
||||||
|
|
Loading…
Reference in New Issue