added methods for Client to send and receive messages
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#include "tlibc/errors.h"
|
||||
#include "tlibc/time.h"
|
||||
#include "tlibc/magic.h"
|
||||
|
||||
/// requires tlibc and tlibtoml init
|
||||
Result(void) TcpChat_init();
|
||||
@@ -63,6 +65,7 @@ typedef void (*LogFunction_t)(void* logger, cstr context, LogSeverity severity,
|
||||
#define logWarn(format, ...) log(LogSeverity_Warn, format ,##__VA_ARGS__)
|
||||
#define logError(format, ...) log(LogSeverity_Error, format ,##__VA_ARGS__)
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Server //
|
||||
@@ -82,6 +85,7 @@ void Server_free(Server* server);
|
||||
|
||||
Result(void) Server_run(Server* server);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Client //
|
||||
@@ -117,3 +121,15 @@ Result(void) Client_register(Client* self, i64* out_user_id);
|
||||
|
||||
/// Authorize on connected server
|
||||
Result(void) Client_login(Client* self, i64* out_user_id, i64* out_landing_channel_id);
|
||||
|
||||
/// @param out_timestamp timestamp received from server
|
||||
/// @return message id received from server
|
||||
Result(i64) Client_sendMessage(Client* self, i64 channel_id, Array(u8) content, DateTime* out_timestamp);
|
||||
|
||||
/// Receive a bunch of messages from the server to a client internal buffer
|
||||
/// @return number of messages received
|
||||
Result(u32) Client_receiveMessageBlock(Client* self, i64 channel_id, i64 first_message_id, u32 messages_count);
|
||||
|
||||
/// Read message saved in client internal buffer.
|
||||
/// @return number of bytes written in dst_content
|
||||
Result(u32) Client_popMessage(Client* self, Array(u8) dst_content, i64* message_id, i64* sender_id, DateTime* timestamp_utc);
|
||||
|
||||
Reference in New Issue
Block a user