Compare commits

...

4 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire 2d1db7b1ef BaseMessage
- Added decoding support for `SEND_CHANNEL_MESG_REP` and compacted
2023-11-21 14:00:27 +02:00
Tristan B. Velloza Kildaire ad9c01f490 CommandType
- Added missing `SEND_CHANNEL_MESG_REP` enum member
2023-11-21 13:54:38 +02:00
Tristan B. Velloza Kildaire f48e95887f ChannelMessage
- Added status field
- Added required methods
2023-11-21 13:52:22 +02:00
Tristan B. Velloza Kildaire 9dadb5aec9 Status
- Added `UNSET` to be `Status.init`'s value
2023-11-21 13:50:38 +02:00
3 changed files with 37 additions and 6 deletions

View File

@ -29,6 +29,7 @@ public enum MessageType
*/
public enum Status
{
UNSET,
GOOD,
BAD_ARGS,
NOT_AUTHD,
@ -187,6 +188,14 @@ public enum CommandType
*/
CHANNEL_SEND_MESSAGE,
/**
* Channel message (reply)
*
* Status on if message was
* sent or not
*/
SEND_CHANNEL_MESG_REP,
/**
* Membership (join)
*

View File

@ -154,12 +154,11 @@ public class BaseMessage
import davinci.c2s.channels : ChannelEnumerateReply;
message.command = Command.decodeTo!(ChannelEnumerateReply)(payload);
}
else if(message.commandType == CommandType.CHANNEL_SEND_MESSAGE)
{
import davinci.c2s.channels : ChannelMessage;
message.command = Command.decodeTo!(ChannelMessage)(payload);
}
else if(message.commandType == CommandType.CHANNEL_NEW_MESSAGE)
else if(
message.commandType == CommandType.CHANNEL_NEW_MESSAGE ||
message.commandType == CommandType.CHANNEL_SEND_MESSAGE ||
message.commandType == CommandType.SEND_CHANNEL_MESG_REP
)
{
import davinci.c2s.channels : ChannelMessage;
message.command = Command.decodeTo!(ChannelMessage)(payload);

View File

@ -75,6 +75,8 @@ public final class ChannelMessage : Command
// TODO: Add mime-type here
private string data;
private Status status;
this()
{
registerClass!(typeof(this));
@ -117,6 +119,27 @@ public final class ChannelMessage : Command
{
return data;
}
public ChannelMessage messageDelivered()
{
return setStatus(Status.GOOD);
}
public ChannelMessage setStatus(Status status)
{
this.status = status;
return this;
}
public Status getStatus()
{
return this.status;
}
public bool wasDelivered()
{
return getStatus() == Status.GOOD;
}
}