mirror of
https://github.com/deavmi/birchwood
synced 2024-09-20 13:02:54 +02:00
Client
- Updated `command(Message)` to use `sendMessage(Message)` - Updated the `PongSignal` event handler to use `sendMessage(Message)` when sending the pong back - Make `quit()` use the new `sendMessage(Message)` - Disabled old `sendMessage(string)`
This commit is contained in:
parent
2b25f4933a
commit
75155795fa
@ -440,13 +440,8 @@ public class Client : Thread
|
|||||||
*/
|
*/
|
||||||
public void command(Message message)
|
public void command(Message message)
|
||||||
{
|
{
|
||||||
/* Encode according to EBNF format */
|
|
||||||
// TODO: Validty check
|
|
||||||
// TODO: Make `Message.encode()` actually encode instead of empty string
|
|
||||||
string stringToSend = message.encode();
|
|
||||||
|
|
||||||
/* Send the message */
|
/* Send the message */
|
||||||
sendMessage(stringToSend);
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -553,8 +548,9 @@ public class Client : Thread
|
|||||||
PongEvent pongEvent = cast(PongEvent)e;
|
PongEvent pongEvent = cast(PongEvent)e;
|
||||||
assert(pongEvent);
|
assert(pongEvent);
|
||||||
|
|
||||||
string messageToSend = "PONG "~pongEvent.getID();
|
// string messageToSend = "PONG "~pongEvent.getID();
|
||||||
client.sendMessage(messageToSend);
|
Message pongMessage = new Message("", "PONG", pongEvent.getID());
|
||||||
|
client.sendMessage(pongMessage);
|
||||||
logger.log("Ponged back with "~pongEvent.getID());
|
logger.log("Ponged back with "~pongEvent.getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -632,24 +628,24 @@ public class Client : Thread
|
|||||||
receiver.rq(message);
|
receiver.rq(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Sends a message to the server by enqueuing it on
|
// * Sends a message to the server by enqueuing it on
|
||||||
* the client-side send queue
|
// * the client-side send queue
|
||||||
*
|
// *
|
||||||
* Params:
|
// * Params:
|
||||||
* messageOut = the message to send
|
// * messageOut = the message to send
|
||||||
*/
|
// */
|
||||||
private void sendMessage(string messageOut)
|
// private void sendMessage(string messageOut)
|
||||||
{
|
// {
|
||||||
// TODO: Do message splits here
|
// // TODO: Do message splits here
|
||||||
|
|
||||||
|
|
||||||
/* Encode the mesage */
|
// /* Encode the mesage */
|
||||||
ubyte[] encodedMessage = encodeMessage(messageOut);
|
// ubyte[] encodedMessage = encodeMessage(messageOut);
|
||||||
|
|
||||||
/* Enqueue the message to the send queue */
|
// /* Enqueue the message to the send queue */
|
||||||
sender.sq(encodedMessage);
|
// sender.sq(encodedMessage);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to the server by enqueuing it on
|
* Sends a message to the server by enqueuing it on
|
||||||
@ -685,7 +681,7 @@ public class Client : Thread
|
|||||||
{
|
{
|
||||||
/* Generate the quit command using the custom quit message */
|
/* Generate the quit command using the custom quit message */
|
||||||
Message quitCommand = new Message("", "QUIT", connInfo.quitMessage);
|
Message quitCommand = new Message("", "QUIT", connInfo.quitMessage);
|
||||||
sendMessage(quitCommand.encode());
|
sendMessage(quitCommand);
|
||||||
|
|
||||||
/* TODO: I don't know how long we should wait here */
|
/* TODO: I don't know how long we should wait here */
|
||||||
Thread.sleep(dur!("seconds")(1));
|
Thread.sleep(dur!("seconds")(1));
|
||||||
|
Loading…
Reference in New Issue
Block a user