1
0
mirror of https://github.com/deavmi/birchwood synced 2024-09-20 12:23:32 +02:00

Merge pull request #17 from deavmi/rfc2812

Rfc2812
This commit is contained in:
Tristan B. Velloza Kildaire 2023-03-16 12:58:08 +02:00 committed by GitHub
commit 49500580c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 179 additions and 141 deletions

View File

@ -117,6 +117,10 @@ public class Client : Thread
logger.log("Generic("~message.getCommand()~", "~message.getFrom()~"): "~message.getParams());
}
// TODO: Hook certain ones default style with an implemenation
// ... for things that the client can learn from
// TODO: comment
/**
* Called on command replies
*
@ -125,8 +129,18 @@ public class Client : Thread
*/
public void onCommandReply(Message commandReply)
{
// TODO: Add numeric response check here for CERTAIN ones which add to client
// ... state
/* Default implementation */
logger.log("Response("~to!(string)(commandReply.getReplyType())~", "~commandReply.getFrom()~"): "~commandReply.toString());
import birchwood.protocol.constants : ReplyType;
if(commandReply.getReplyType() == ReplyType.RPL_BOUNCE)
{
logger.log("Take a look:\n\n"~commandReply.getParams());
}
}
/**
@ -619,6 +633,9 @@ public class Client : Thread
// If the command is numeric then it is a reply of some sorts
else if(ircMessage.isResponseMessage())
{
// TODO: Add numeric response check here for CERTAIN ones which add to client
// ... state
/* Call the command reply handler */
onCommandReply(ircMessage);
}

View File

@ -1,8 +1,14 @@
module birchwood.protocol.constants;
/* Reply object */
/**
* The type of numeric response
*/
public enum ReplyType : ulong
{
/**
* rfc 1459
*/
/* Error replies */
ERR_NOSUCHNICK = 401,
ERR_NOSUCHSERVER = 402,
@ -144,5 +150,20 @@ module birchwood.protocol.constants;
ERR_BADCHANMASK = 476,
/**
* rfc 2812
*/
RPL_WELCOME = 001,
RPL_YOURHOST = 002,
RPL_CREATED = 003,
RPL_MYINFO = 004,
RPL_BOUNCE = 005, // TODO: We care about the key-value pairs here in RPL_BOUNCE
ERR_NOCHANMODES = 477,
/**
* If no code is matched then this is the default
*/
BIRCHWOOD_UNKNOWN_RESP_CODE = 0
}