1
0
mirror of https://github.com/deavmi/birchwood synced 2024-09-20 16:23:39 +02:00
- Fixed compilation error by adding missing `encodeMessage(string)` call
- If the encoded message (CRLF included) is over 512 bytes then throw an exception

Exceptions

- Added new `ErrorType` enum member
This commit is contained in:
Tristan B. Velloza Kildaire 2023-03-15 08:24:56 +02:00
parent 256369abc5
commit 11dbd1a96f
2 changed files with 14 additions and 4 deletions

View File

@ -652,10 +652,19 @@ public class Client : Thread
private void sendMessage(Message message) private void sendMessage(Message message)
{ {
/* Encode the message */ /* Encode the message */
ubyte[] encodedMessage = message.encode(); ubyte[] encodedMessage = encodeMessage(message.encode());
/* Enqueue the message to the send queue */ /* If the message is 512 bytes or less then send */
sender.sq(encodedMessage); if(encodedMessage.length <= 512)
{
/* Enqueue the message to the send queue */
sender.sq(encodedMessage);
}
/* If above then throw an exception */
else
{
throw new BirchwoodException(BirchwoodException.ErrorType.COMMAND_TOO_LONG);
}
} }
/** /**

View File

@ -13,7 +13,8 @@ public class BirchwoodException : Exception
EMPTY_PARAMS, EMPTY_PARAMS,
INVALID_CHANNEL_NAME, INVALID_CHANNEL_NAME,
INVALID_NICK_NAME, INVALID_NICK_NAME,
ILLEGAL_CHARACTERS ILLEGAL_CHARACTERS,
COMMAND_TOO_LONG
} }
private ErrorType errType; private ErrorType errType;