From 5f5fb841ae0019418cd73507b83d3903807d91aa Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Tue, 21 Nov 2023 14:11:43 +0200 Subject: [PATCH] Client - Working on adding support for sending of messages --- source/dante/client.d | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/source/dante/client.d b/source/dante/client.d index aead65a..a132ae9 100644 --- a/source/dante/client.d +++ b/source/dante/client.d @@ -194,6 +194,41 @@ public class DanteClient return sendMessage_imp([recipient], message); } + public void sendMessage(string[] recipients, string message) + { + import davinci.c2s.channels : ChannelMessage; + import davinci; + BaseMessage response = cast(BaseMessage)sendMessage_imp(recipients, message).await().getValue().value.object; + + // TODO: For absolute sanity we should check that + // ... it actually decoded to the type we EXPECT + // ... to be here (this would safeguard against + // ... bad server implementations) + // TODO: Make teh below a `mixin template` + Command responseCommand = response.getCommand(); + ChannelMessage chanMemResp = cast(ChannelMessage)responseCommand; + + if(chanMemResp is null) + { + throw ProtocolException.expectedMessageKind(ChannelMessage.classinfo, responseCommand); + } + + // TODO: Add checking here + // if(chanMemResp.wasGood()) + // { + // return chanMemResp.getMembers(); + // } + // else + // { + // throw new CommandException("Could not enumerate members of channel '"~channelName~"'"); + // } + } + + public void sendMessage(string recipient, string message) + { + sendMessage([recipient], message); + } + public Future enumerateMembers_imp(string channelName) { import davinci.c2s.channels : ChannelMembership;