From 40aca0691949f41c27704c1f8c4d05fae655cf26 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 21 Aug 2022 11:20:37 +0200 Subject: Implement message sending --- net.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'net.c') diff --git a/net.c b/net.c index c37847d..dc0f5de 100644 --- a/net.c +++ b/net.c @@ -215,3 +215,20 @@ void net_disconnect(void) { state = DISCONNECTED; } + +void net_send_message(const char* sender, const char* content, + const char* recipient) { + + // TODO what happens if client is disconnected and this function is called? + + char* uuid = xmpp_uuid_gen(ctx); + + xmpp_stanza_t* msg = xmpp_message_new(ctx, "chat", recipient, uuid); + xmpp_stanza_set_from(msg, sender); + xmpp_message_set_body(msg, content); + xmpp_send(conn, msg); + + xmpp_free(ctx, msg); + xmpp_free(ctx, uuid); + +} -- cgit v1.2.3-70-g09d2