1#ifndef WAVELENGTH_MESSAGE_SERVICE_H
2#define WAVELENGTH_MESSAGE_SERVICE_H
64 static bool SendAudioData(
const QString &frequency,
const QByteArray &audio_data);
87 bool SendFile(
const QString &file_path,
const QString &progress_message_id = QString());
100 bool SendFileToServer(
const QString &json_message,
const QString &frequency,
const QString &progress_message_id);
143 if (progress_message_id.isEmpty())
return;
156 const QString &progress_message_id);
164 void messageSent(QString frequency,
const QString &formatted_message);
186 void sendJsonViaSocket(
const QString &json_message, QString frequency,
const QString &progress_message_id);
MessageService(const MessageService &)=delete
Deleted copy constructor to prevent copying.
void removeProgressMessage(const QString &message_id)
Emitted after a file transfer is complete (success or failure) to remove the progress message.
void audioDataReceived(QString frequency, const QByteArray &audio_data)
Emitted when raw audio data is received via a binary WebSocket message. Relayed from WavelengthMessag...
void remoteAudioAmplitudeUpdate(QString frequency, qreal amplitude)
Emitted when the server sends an update about the remote audio amplitude (optional)....
static MessageService * GetInstance()
Gets the singleton instance of the MessageService.
Definition message_service.h:26
void HandleSendJsonViaSocket(const QString &json_message, const QString &frequency, const QString &progress_message_id)
Slot connected to the sendJsonViaSocket signal. Performs the actual sending of a JSON message....
Definition message_service.cpp:274
void progressMessageUpdated(const QString &message_id, const QString &message)
Emitted during file processing and sending to update the status display.
~MessageService() override=default
Private destructor.
void ClearSentMessageCache()
Clears the internal cache of sent message contents.
Definition message_service.h:115
QString client_id_
Stores the client ID associated with this service instance.
Definition message_service.h:258
static bool SendPttRequest(const QString &frequency)
Sends a Push-to-Talk (PTT) request message for the specified frequency. Constructs a JSON message of ...
Definition message_service.cpp:14
void UpdateProgressMessage(const QString &progress_message_id, const QString &message)
Slot to update a progress message associated with a file transfer. Emits the progressMessageUpdated s...
Definition message_service.h:142
QMap< QString, QString > * GetSentMessageCache()
Gets a pointer to the internal cache of sent message contents. The cache maps message ID to message c...
Definition message_service.h:108
static bool SendPttRelease(const QString &frequency)
Sends a Push-to-Talk (PTT) release message for the specified frequency. Constructs a JSON message of ...
Definition message_service.cpp:28
void pttDenied(QString frequency, QString reason)
Emitted when the server denies permission to transmit audio (Push-to-Talk). Relayed from WavelengthMe...
void pttStopReceiving(QString frequency)
Emitted when the currently transmitting user stops sending audio. Relayed from WavelengthMessageProce...
static bool SendAudioData(const QString &frequency, const QByteArray &audio_data)
Sends raw audio data as a binary message for the specified frequency. Used for transmitting audio dur...
Definition message_service.cpp:42
void messageSent(QString frequency, const QString &formatted_message)
Emitted immediately after a text message is successfully sent via the socket.
void sendJsonViaSocket(const QString &json_message, QString frequency, const QString &progress_message_id)
Internal signal emitted by the background file processing task when the JSON message is ready to be s...
void pttGranted(QString frequency)
Emitted when the server grants permission to transmit audio (Push-to-Talk). Relayed from WavelengthMe...
QMap< QString, QString > sent_messages_
Cache storing the content of recently sent text messages, mapped by message ID.
Definition message_service.h:256
bool SendFileToServer(const QString &json_message, const QString &frequency, const QString &progress_message_id)
Sends a pre-formatted JSON message (typically containing file data) to the server....
Definition message_service.cpp:240
void pttStartReceiving(QString frequency, QString sender_id)
Emitted when another user starts transmitting audio on the frequency. Relayed from WavelengthMessageP...
bool SendTextMessage(const QString &message)
Sends a text message to the currently active frequency. Retrieves the active frequency and socket fro...
Definition message_service.cpp:50
static QWebSocket * GetSocketForFrequency(const QString &frequency)
Helper function to retrieve the active WebSocket connection for a given frequency....
Definition message_service.cpp:309
QString GetClientId() const
Gets the client ID currently associated with this service instance.
Definition message_service.h:123
void SetClientId(const QString &clientId)
Sets the client ID for this service instance.
Definition message_service.h:131
MessageService & operator=(const MessageService &)=delete
Deleted assignment operator to prevent assignment.
bool SendFile(const QString &file_path, const QString &progress_message_id=QString())
Initiates the process of sending a file to the currently active frequency. Reads the file,...
Definition message_service.cpp:102