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

Cleaned up and added TODOs

This commit is contained in:
Tristan B. Kildaire 2020-05-15 16:31:35 +02:00
parent 0b5ca124d6
commit 2b54142439

View file

@ -63,6 +63,10 @@ public final class BesterConnection : Thread
debugPrint("New client handler spawned for " ~ clientConnection.remoteAddress().toAddrString()); debugPrint("New client handler spawned for " ~ clientConnection.remoteAddress().toAddrString());
} }
/**
* Shutdown the BesterConnection by stopping
* the read-write loop and closing the socket.
*/
public void shutdown() public void shutdown()
{ {
/* TODO: Send message posssibly, think about this for listeners and informers (etc.) too */ /* TODO: Send message posssibly, think about this for listeners and informers (etc.) too */
@ -74,6 +78,9 @@ public final class BesterConnection : Thread
return username ~ "@" ~ clientConnection.remoteAddress().toAddrString(); return username ~ "@" ~ clientConnection.remoteAddress().toAddrString();
} }
/**
* Returns an array of the username and password.
*/
public string[] getCredentials() public string[] getCredentials()
{ {
return [username, password]; return [username, password];
@ -83,7 +90,7 @@ public final class BesterConnection : Thread
private void run() private void run()
{ {
debugPrint("<<< Begin read/send loop >>>"); debugPrint("<<< Begin read/send loop >>>");
while(isActive) /*TODO: Remove and also make the stting of this kak not be closing socket */ while(isActive)
{ {
/* Received JSON message */ /* Received JSON message */
JSONValue receivedMessage; JSONValue receivedMessage;
@ -103,7 +110,7 @@ public final class BesterConnection : Thread
if(connectionType == Scope.SERVER) if(connectionType == Scope.SERVER)
{ {
debugPrint("Server connection done, closing BesterConnection."); debugPrint("Server connection done, closing BesterConnection.");
isActive = false; shutdown();
} }
} }
catch(BesterException exception) catch(BesterException exception)
@ -272,15 +279,12 @@ public final class BesterConnection : Thread
{ {
/* In the case of an error with the message handler, send an error to the client/server */ /* In the case of an error with the message handler, send an error to the client/server */
/* TODO: Send error here */ /* TODO: Clean up comments */
//JSONValue errorResponse;
//errorResponse["dd"] = 2;
//debugPrint("Response error");
// dispatchStatus = false;
/* Send error message to client */ /* Send error message to client */
sendStatusReport(StatusType.FAILURE, payloadTag); sendStatusReport(StatusType.FAILURE, payloadTag);
} }
/* TODO: Be more specific with errors and reporting in the future */
catch(Exception e) catch(Exception e)
{ {
/* TODO: Remove me */ /* TODO: Remove me */
@ -291,7 +295,6 @@ public final class BesterConnection : Thread
} }
debugPrint("Handler section done (for client)"); debugPrint("Handler section done (for client)");
/* TODO: Handle response */
} }
/* If no message handler for the specified type could be found */ /* If no message handler for the specified type could be found */
else else