Had a mistake migrating to the new bformat, now migrated almost.

This commit is contained in:
Tristan B. Kildaire 2020-06-16 18:46:26 +02:00
parent c4a4d46264
commit 261448159f
3 changed files with 12 additions and 9 deletions

View File

@ -99,9 +99,7 @@ public final class BesterConnection : Thread
try try
{ {
/* Receive a message */ /* Receive a message */
byte[] receivedBytes; receiveMessage(clientConnection, receivedMessage);
receiveMessage(clientConnection, receivedBytes);
receivedMessage = parseJSON(cast(string)receivedBytes);
/** /**
* If the message was received successfully then * If the message was received successfully then
@ -220,7 +218,7 @@ public final class BesterConnection : Thread
try try
{ {
/* Send the message */ /* Send the message */
sendMessage(clientConnection, cast(byte[])toJSON(dummyMessage)); sendMessage(clientConnection, dummyMessage);
} }
catch(NetworkException e) catch(NetworkException e)
{ {
@ -348,7 +346,7 @@ public final class BesterConnection : Thread
try try
{ {
/* Send the message */ /* Send the message */
sendMessage(clientConnection, cast(byte[])toJSON(statusMessage)); sendMessage(clientConnection, statusMessage);
} }
catch(NetworkException e) catch(NetworkException e)
{ {

View File

@ -211,7 +211,7 @@ public final class HandlerResponse
/* Send the message to the client */ /* Send the message to the client */
debugPrint("Sending handler's response to client \"" ~ clientConnection.toString() ~ "\"..."); debugPrint("Sending handler's response to client \"" ~ clientConnection.toString() ~ "\"...");
sendMessage(clientSocket, cast(byte[])toJSON(clientPayload)); sendMessage(clientSocket, clientPayload);
debugPrint("Sending handler's response to client \"" ~ clientConnection.toString() ~ "\"... [sent]"); debugPrint("Sending handler's response to client \"" ~ clientConnection.toString() ~ "\"... [sent]");
} }
catch(SocketOSException exception) catch(SocketOSException exception)
@ -284,7 +284,7 @@ public final class HandlerResponse
/* Send the payload */ /* Send the payload */
debugPrint("Sending handler's response to server \"" ~ serverConnection.toString() ~ "\"..."); debugPrint("Sending handler's response to server \"" ~ serverConnection.toString() ~ "\"...");
sendMessage(serverConnection, cast(byte[])toJSON(serverPayload)); sendMessage(serverConnection, serverPayload);
debugPrint("Sending handler's response to server \"" ~ serverConnection.toString() ~ "\"... [sent]"); debugPrint("Sending handler's response to server \"" ~ serverConnection.toString() ~ "\"... [sent]");
/* Close the connection to the server */ /* Close the connection to the server */

View File

@ -14,10 +14,15 @@ import bmessage : bformatreceiveMessage = receiveMessage, bformatsendMessage = s
*/ */
public void receiveMessage(Socket originator, ref JSONValue receiveMessage) public void receiveMessage(Socket originator, ref JSONValue receiveMessage)
{ {
if(!bformatreceiveMessage(originator, receiveMessage)) /* The received bytes */
byte[] receivedBytes;
if(!bformatreceiveMessage(originator, receivedBytes))
{ {
throw new NetworkException(originator); throw new NetworkException(originator);
} }
receiveMessage = parseJSON(cast(string)receivedBytes);
} }
/** /**
@ -31,7 +36,7 @@ public void receiveMessage(Socket originator, ref JSONValue receiveMessage)
*/ */
public void sendMessage(Socket recipient, JSONValue jsonMessage) public void sendMessage(Socket recipient, JSONValue jsonMessage)
{ {
if(!bformatsendMessage(recipient, jsonMessage)) if(!bformatsendMessage(recipient, cast(byte[])toJSON(jsonMessage)))
{ {
throw new NetworkException(recipient); throw new NetworkException(recipient);
} }