Open JonathanDUFOUR opened 5 months ago
I'd prefer to use
int irc_command(Client &sender, std::string const ¶meters);
Instead of bool because it would allow us to send detailed error codes via the return of the function.
We can do that, then I suggest also adding an enum to list every different return code for our internal functions, like:
enum StatusCode
{
Success,
ErrorFormatReply,
ErrorClientSendMessage,
/* ... */
};
I suggest that we use this format to implement command instead :
StatusCode cmd(Client &sender, std::vector<std::string> const ¶meters);
Using a vector of parameters is simpler than using a string as they are already separated. Do you agree ?
After thinking about the nature of the errors that can occur and would return a StatusCode
different from Success
, it seems that they are all triggered by a critical internal error, with different possible origins. Thus, we decided to throw exceptions for these kinds of errors, instead of returning a StatusCode
, and the new prototype is now:
void irc_command(Client &sender, std::vector<std::string> const ¶meters);
Closing this issue was a mistake.
Now that our documentation is ready, we should start implementing the IRC commands. There is a list of the commands that we must implement:
To be able to make a map of these commands, and jump to the correct one when the server receives a message from a client, we should have the same prototype for every command. I suggest the following one: