Singleton class responsible for processing incoming WebSocket messages for specific wavelengths.
More...
#include <message_processor.h>
|
| void | audioDataReceived (QString frequency, const QByteArray &audio_data) |
| | Emitted when raw audio data is received via a binary WebSocket message.
|
| |
| void | messageReceived (QString frequency, const QString &formatted_message) |
| | Emitted when a regular chat message (text or attachment placeholder) is processed.
|
| |
| void | pttDenied (QString frequency, QString reason) |
| | Emitted when the server denies permission to transmit audio (Push-to-Talk).
|
| |
| void | pttGranted (QString frequency) |
| | Emitted when the server grants permission to transmit audio (Push-to-Talk).
|
| |
| void | pttStartReceiving (QString frequency, QString sender_id) |
| | Emitted when another user starts transmitting audio on the frequency.
|
| |
| void | pttStopReceiving (QString frequency) |
| | Emitted when the currently transmitting user stops sending audio.
|
| |
| void | remoteAudioAmplitudeUpdate (QString frequency, qreal amplitude) |
| | Emitted when the server sends an update about the remote audio amplitude (optional).
|
| |
| void | systemMessage (QString frequency, const QString &formatted_message) |
| | Emitted when a system event message (e.g., user join/leave) is processed.
|
| |
| void | userKicked (QString frequency, const QString &reason) |
| | Emitted when the current user is kicked from a frequency.
|
| |
| void | wavelengthClosed (QString frequency) |
| | Emitted when a wavelength is closed (either by host or server command).
|
| |
|
| | MessageProcessor (const MessageProcessor &)=delete |
| | Deleted copy constructor to prevent copying.
|
| |
| MessageProcessor & | operator= (const MessageProcessor &)=delete |
| | Deleted assignment operator to prevent assignment.
|
| |
| void | ProcessIncomingBinaryMessage (const QByteArray &message, const QString &frequency) |
| | Processes an incoming binary message (expected to be audio data) received from the WebSocket. Emits the audioDataReceived signal with the raw audio data.
|
| |
| void | ProcessIncomingMessage (const QString &message, const QString &frequency) |
| | Processes an incoming text message (JSON) received from the WebSocket. Parses the JSON, checks message ID, validates frequency, determines a message type, and calls the corresponding private processing method (e.g., ProcessMessageContent, ProcessSystemCommand).
|
| |
| void | SetSocketMessageHandlers (QWebSocket *socket, QString frequency) |
| | Connects the appropriate slots of this processor to the signals of a given QWebSocket. Disconnects any previous handlers for the socket first. Connects textMessageReceived and binaryMessageReceived signals to the respective processing methods of this class, capturing the associated frequency. Also connects the socket's error signal for logging.
|
| |
|
| | MessageProcessor (QObject *parent=nullptr) |
| | Private constructor to enforce the singleton pattern. Connects internal signals to the corresponding slots in WavelengthMessageService.
|
| |
| void | ProcessMessageContent (const QJsonObject &message_object, const QString &frequency, const QString &message_id) |
| | Processes messages of type "message" or "send_message". Checks for duplicates, handles attachments (storing data and creating placeholders if necessary), formats the message using MessageFormatter, and emits the messageReceived signal.
|
| |
| void | ProcessSystemCommand (const QJsonObject &message_object, const QString &frequency) |
| | Processes messages of type "system_command". Handles commands like "ping", "close_wavelength", "kick_user". Emits appropriate signals (e.g., userKicked, wavelengthClosed).
|
| |
| void | ProcessUserJoined (const QJsonObject &message_object, const QString &frequency) |
| | Processes messages of type "user_joined". Formats a system message indicating a user joined and emits the systemMessage signal.
|
| |
| void | ProcessUserLeft (const QJsonObject &message_object, const QString &frequency) |
| | Processes messages of type "user_left". Formats a system message indicating a user left and emits the systemMessage signal.
|
| |
| void | ProcessWavelengthClosed (const QString &frequency) |
| | Processes messages indicating a wavelength was closed (e.g., "wavelength_closed", "close_wavelength" command). Updates the WavelengthRegistry and emits the wavelengthClosed signal.
|
| |
| | ~MessageProcessor () override=default |
| | Private destructor.
|
| |
Singleton class responsible for processing incoming WebSocket messages for specific wavelengths.
This class acts as the central hub for interpreting messages received from the server for a given frequency (wavelength). It parses JSON messages, identifies their type, checks for duplicates, validates frequency matching, and dispatches them to appropriate private handler methods. It also handles incoming binary data (audio). It emits signals based on the processed message content (e.g., new message, user joined/left, PTT events, audio data). It collaborates with MessageHandler for parsing and ID management, MessageFormatter for creating displayable HTML, and AttachmentDataStore for handling attachments.
◆ MessageProcessor() [1/2]
Deleted copy constructor to prevent copying.
◆ MessageProcessor() [2/2]
| MessageProcessor::MessageProcessor |
( |
QObject * | parent = nullptr | ) |
|
|
explicitprivate |
Private constructor to enforce the singleton pattern. Connects internal signals to the corresponding slots in WavelengthMessageService.
- Parameters
-
| parent | Optional parent QObject. |
◆ ~MessageProcessor()
| MessageProcessor::~MessageProcessor |
( |
| ) |
|
|
overrideprivatedefault |
◆ AreFrequenciesEqual()
| static bool MessageProcessor::AreFrequenciesEqual |
( |
const QString & | frequency1, |
|
|
const QString & | frequency2 ) |
|
inlinestatic |
Compares two frequency strings for equality. Simple string comparison.
- Parameters
-
| frequency1 | The first frequency string. |
| frequency2 | The second frequency string. |
- Returns
- True if the strings are identical, false otherwise.
◆ audioDataReceived
| void MessageProcessor::audioDataReceived |
( |
QString | frequency, |
|
|
const QByteArray & | audio_data ) |
|
signal |
Emitted when raw audio data is received via a binary WebSocket message.
- Parameters
-
| frequency | The frequency the audio data belongs to. |
| audio_data | The raw audio data bytes. |
◆ GetInstance()
◆ messageReceived
| void MessageProcessor::messageReceived |
( |
QString | frequency, |
|
|
const QString & | formatted_message ) |
|
signal |
Emitted when a regular chat message (text or attachment placeholder) is processed.
- Parameters
-
| frequency | The frequency the message belongs to. |
| formatted_message | The HTML-formatted message string for display. |
◆ operator=()
Deleted assignment operator to prevent assignment.
◆ ProcessIncomingBinaryMessage()
| void MessageProcessor::ProcessIncomingBinaryMessage |
( |
const QByteArray & | message, |
|
|
const QString & | frequency ) |
Processes an incoming binary message (expected to be audio data) received from the WebSocket. Emits the audioDataReceived signal with the raw audio data.
- Parameters
-
| message | The raw binary data (QByteArray). |
| frequency | The frequency/wavelength this data belongs to. |
◆ ProcessIncomingMessage()
| void MessageProcessor::ProcessIncomingMessage |
( |
const QString & | message, |
|
|
const QString & | frequency ) |
Processes an incoming text message (JSON) received from the WebSocket. Parses the JSON, checks message ID, validates frequency, determines a message type, and calls the corresponding private processing method (e.g., ProcessMessageContent, ProcessSystemCommand).
- Parameters
-
| message | The raw JSON message string. |
| frequency | Frequency/wavelength this message belongs to. |
◆ ProcessMessageContent()
| void MessageProcessor::ProcessMessageContent |
( |
const QJsonObject & | message_object, |
|
|
const QString & | frequency, |
|
|
const QString & | message_id ) |
|
private |
Processes messages of type "message" or "send_message". Checks for duplicates, handles attachments (storing data and creating placeholders if necessary), formats the message using MessageFormatter, and emits the messageReceived signal.
- Parameters
-
| message_object | The parsed JSON object of the message. |
| frequency | The frequency the message belongs to. |
| message_id | The unique ID of the message. |
◆ ProcessSystemCommand()
| void MessageProcessor::ProcessSystemCommand |
( |
const QJsonObject & | message_object, |
|
|
const QString & | frequency ) |
|
private |
Processes messages of type "system_command". Handles commands like "ping", "close_wavelength", "kick_user". Emits appropriate signals (e.g., userKicked, wavelengthClosed).
- Parameters
-
| message_object | The parsed JSON object of the command. |
| frequency | The frequency the command applies to. |
◆ ProcessUserJoined()
| void MessageProcessor::ProcessUserJoined |
( |
const QJsonObject & | message_object, |
|
|
const QString & | frequency ) |
|
private |
Processes messages of type "user_joined". Formats a system message indicating a user joined and emits the systemMessage signal.
- Parameters
-
| message_object | The parsed JSON object of the event. |
| frequency | The frequency the user joined. |
◆ ProcessUserLeft()
| void MessageProcessor::ProcessUserLeft |
( |
const QJsonObject & | message_object, |
|
|
const QString & | frequency ) |
|
private |
Processes messages of type "user_left". Formats a system message indicating a user left and emits the systemMessage signal.
- Parameters
-
| message_object | The parsed JSON object of the event. |
| frequency | The frequency the user left. |
◆ ProcessWavelengthClosed()
| void MessageProcessor::ProcessWavelengthClosed |
( |
const QString & | frequency | ) |
|
|
private |
Processes messages indicating a wavelength was closed (e.g., "wavelength_closed", "close_wavelength" command). Updates the WavelengthRegistry and emits the wavelengthClosed signal.
- Parameters
-
| frequency | The frequency that was closed. |
◆ pttDenied
| void MessageProcessor::pttDenied |
( |
QString | frequency, |
|
|
QString | reason ) |
|
signal |
Emitted when the server denies permission to transmit audio (Push-to-Talk).
- Parameters
-
| frequency | The frequency for which PTT was denied. |
| reason | The reason provided for the denial. |
◆ pttGranted
| void MessageProcessor::pttGranted |
( |
QString | frequency | ) |
|
|
signal |
Emitted when the server grants permission to transmit audio (Push-to-Talk).
- Parameters
-
| frequency | The frequency for which PTT was granted. |
◆ pttStartReceiving
| void MessageProcessor::pttStartReceiving |
( |
QString | frequency, |
|
|
QString | sender_id ) |
|
signal |
Emitted when another user starts transmitting audio on the frequency.
- Parameters
-
| frequency | The frequency where transmission started. |
| sender_id | The ID of the user transmitting. |
◆ pttStopReceiving
| void MessageProcessor::pttStopReceiving |
( |
QString | frequency | ) |
|
|
signal |
Emitted when the currently transmitting user stops sending audio.
- Parameters
-
| frequency | The frequency where transmission stopped. |
◆ remoteAudioAmplitudeUpdate
| void MessageProcessor::remoteAudioAmplitudeUpdate |
( |
QString | frequency, |
|
|
qreal | amplitude ) |
|
signal |
Emitted when the server sends an update about the remote audio amplitude (optional).
- Parameters
-
| frequency | The frequency the amplitude update is for. |
| amplitude | The current amplitude level (typically 0.0 to 1.0). |
◆ SetSocketMessageHandlers()
| void MessageProcessor::SetSocketMessageHandlers |
( |
QWebSocket * | socket, |
|
|
QString | frequency ) |
Connects the appropriate slots of this processor to the signals of a given QWebSocket. Disconnects any previous handlers for the socket first. Connects textMessageReceived and binaryMessageReceived signals to the respective processing methods of this class, capturing the associated frequency. Also connects the socket's error signal for logging.
- Parameters
-
| socket | The QWebSocket instance to connect handlers to. |
| frequency | The frequency associated with this socket connection. |
◆ systemMessage
| void MessageProcessor::systemMessage |
( |
QString | frequency, |
|
|
const QString & | formatted_message ) |
|
signal |
Emitted when a system event message (e.g., user join/leave) is processed.
- Parameters
-
| frequency | The frequency the event occurred on. |
| formatted_message | The HTML-formatted system message string. |
◆ userKicked
| void MessageProcessor::userKicked |
( |
QString | frequency, |
|
|
const QString & | reason ) |
|
signal |
Emitted when the current user is kicked from a frequency.
- Parameters
-
| frequency | The frequency the user was kicked from. |
| reason | The reason provided for the kick. |
◆ wavelengthClosed
| void MessageProcessor::wavelengthClosed |
( |
QString | frequency | ) |
|
|
signal |
Emitted when a wavelength is closed (either by host or server command).
- Parameters
-
| frequency | The frequency that was closed. |
The documentation for this class was generated from the following files: