Updated to new bmessage API.

This commit is contained in:
Tristan B. Kildaire 2020-06-16 18:19:46 +02:00
parent c646b4bf20
commit 9db02f607b
2 changed files with 7 additions and 5 deletions

View File

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

View File

@ -1,6 +1,6 @@
module handlers.response;
import std.json : JSONValue, JSONException, parseJSON;
import std.json : JSONValue, JSONException, parseJSON, toJSON;
import std.conv : to;
import utils.debugging : debugPrint;
import std.string : cmp;
@ -211,7 +211,7 @@ public final class HandlerResponse
/* Send the message to the client */
debugPrint("Sending handler's response to client \"" ~ clientConnection.toString() ~ "\"...");
sendMessage(clientSocket, clientPayload);
sendMessage(clientSocket, cast(byte[])toJSON(clientPayload));
debugPrint("Sending handler's response to client \"" ~ clientConnection.toString() ~ "\"... [sent]");
}
catch(SocketOSException exception)
@ -284,7 +284,7 @@ public final class HandlerResponse
/* Send the payload */
debugPrint("Sending handler's response to server \"" ~ serverConnection.toString() ~ "\"...");
sendMessage(serverConnection, serverPayload);
sendMessage(serverConnection, cast(byte[])toJSON(serverPayload));
debugPrint("Sending handler's response to server \"" ~ serverConnection.toString() ~ "\"... [sent]");
/* Close the connection to the server */