Compare commits

...

3 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire ead47834fb ChannelMessage
- Implemented `setMessage(string data)`
2023-11-20 20:09:47 +02:00
Tristan B. Velloza Kildaire 9d010247f5 ChannelMessage
- `setTo(string[] to)` now uses `setTo(string)`
2023-11-20 20:09:21 +02:00
Tristan B. Velloza Kildaire 4002854c50 Validatable
- Added new interface
2023-11-20 19:56:15 +02:00
2 changed files with 37 additions and 1 deletions

View File

@ -35,6 +35,30 @@ public enum Status
NOT_USER
}
/**
* Support for message validation
* to ensure that it is valid given
* some of its parameters
*/
public interface Validatable
{
/**
* Validates the item returning whether
* this process failed or not
*
* In the case of a failure the ref-based
* argument is updated with the reason
* of failure
*
* Params:
* reason = the reason of failure (if
* any)
* Returns: `true` if the validation
* passes, `false` otherwise
*/
public bool validate(ref string reason);
}
public abstract class Command
{
private byte[] data;
@ -94,6 +118,13 @@ public enum CommandType
SPACER,
NOP_COMMAND,
/**
* Error
*
*
*/
ERROR,
/**
* Unknown command
*

View File

@ -80,11 +80,16 @@ public final class ChannelMessage : Command
registerClass!(typeof(this));
}
public void setMessage(string data)
{
this.data = data;
}
public void setTo(string[] to)
{
foreach(string curTo; to)
{
this.to ~= curTo;
setTo(curTo);
}
}