Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
WavelengthLeaver Class Referencefinal

Singleton class responsible for handling the process of leaving or closing wavelengths. More...

#include <wavelength_leaver.h>

Inheritance diagram for WavelengthLeaver:
Collaboration diagram for WavelengthLeaver:

Signals

void wavelengthClosed (QString frequency)
 Emitted after the host successfully closes a specific wavelength via CloseWavelength().
 
void wavelengthLeft (QString frequency)
 Emitted after the user successfully leaves the active wavelength via LeaveWavelength().
 

Public Member Functions

void CloseWavelength (QString frequency)
 Closes a specific wavelength (only if the current user is the host). Checks if the user is the host for the given frequency. Sends a "close_wavelength" command to the server, closes the WebSocket connection, removes the wavelength from the registry, and emits the wavelengthClosed signal. If the closed wavelength was the active one, sets the active wavelength to "-1".
 
void LeaveWavelength ()
 Leaves the currently active wavelength. Retrieves the active frequency from the registry. If the user is the host, sends a "close_wavelength" command; otherwise, sends a "leave_wavelength" command. Closes the WebSocket connection, removes the wavelength from the registry, sets the active wavelength to "-1", and emits the wavelengthLeft signal.
 

Static Public Member Functions

static WavelengthLeaverGetInstance ()
 Gets the singleton instance of the WavelengthLeaver.
 

Private Member Functions

WavelengthLeaveroperator= (const WavelengthLeaver &)=delete
 Deleted assignment operator to prevent assignment.
 
 WavelengthLeaver (const WavelengthLeaver &)=delete
 Deleted copy constructor to prevent copying.
 
 WavelengthLeaver (QObject *parent=nullptr)
 Private constructor to enforce the singleton pattern.
 
 ~WavelengthLeaver () override=default
 Private destructor.
 

Detailed Description

Singleton class responsible for handling the process of leaving or closing wavelengths.

Provides methods to gracefully disconnect from the currently active wavelength (LeaveWavelength) or to close a specific wavelength if the user is the host (CloseWavelength). It interacts with WavelengthRegistry and MessageHandler to send appropriate commands to the server and update the local state.

Constructor & Destructor Documentation

◆ WavelengthLeaver() [1/2]

WavelengthLeaver::WavelengthLeaver ( QObject * parent = nullptr)
inlineexplicitprivate

Private constructor to enforce the singleton pattern.

Parameters
parentOptional parent QObject.
Here is the caller graph for this function:

◆ ~WavelengthLeaver()

WavelengthLeaver::~WavelengthLeaver ( )
overrideprivatedefault

Private destructor.

◆ WavelengthLeaver() [2/2]

WavelengthLeaver::WavelengthLeaver ( const WavelengthLeaver & )
privatedelete

Deleted copy constructor to prevent copying.

Here is the call graph for this function:

Member Function Documentation

◆ CloseWavelength()

void WavelengthLeaver::CloseWavelength ( QString frequency)

Closes a specific wavelength (only if the current user is the host). Checks if the user is the host for the given frequency. Sends a "close_wavelength" command to the server, closes the WebSocket connection, removes the wavelength from the registry, and emits the wavelengthClosed signal. If the closed wavelength was the active one, sets the active wavelength to "-1".

Parameters
frequencyThe frequency identifier of the wavelength to close.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetInstance()

static WavelengthLeaver * WavelengthLeaver::GetInstance ( )
inlinestatic

Gets the singleton instance of the WavelengthLeaver.

Returns
Pointer to the singleton WavelengthLeaver instance.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LeaveWavelength()

void WavelengthLeaver::LeaveWavelength ( )

Leaves the currently active wavelength. Retrieves the active frequency from the registry. If the user is the host, sends a "close_wavelength" command; otherwise, sends a "leave_wavelength" command. Closes the WebSocket connection, removes the wavelength from the registry, sets the active wavelength to "-1", and emits the wavelengthLeft signal.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

WavelengthLeaver & WavelengthLeaver::operator= ( const WavelengthLeaver & )
privatedelete

Deleted assignment operator to prevent assignment.

Here is the call graph for this function:

◆ wavelengthClosed

void WavelengthLeaver::wavelengthClosed ( QString frequency)
signal

Emitted after the host successfully closes a specific wavelength via CloseWavelength().

Parameters
frequencyThe frequency identifier of the wavelength that was closed.
Here is the caller graph for this function:

◆ wavelengthLeft

void WavelengthLeaver::wavelengthLeft ( QString frequency)
signal

Emitted after the user successfully leaves the active wavelength via LeaveWavelength().

Parameters
frequencyThe frequency identifier of the wavelength that was left.
Here is the caller graph for this function:

The documentation for this class was generated from the following files: