R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ConnectionEvent Class Reference

Event representing a connection state change. More...

#include <NetworkEvent.hpp>

Inheritance diagram for ConnectionEvent:
Inheritance graph
Collaboration diagram for ConnectionEvent:
Collaboration graph

Public Types

enum class  Status { CONNECTED , DISCONNECTED , FAILED }
 Connection status states. More...
 

Public Member Functions

 ConnectionEvent (Status status, const std::string &message="")
 Construct a connection event.
 
Status getStatus () const
 Get the connection status.
 
const std::string & getMessage () const
 Get the status message.
 
- Public Member Functions inherited from IEvent
virtual ~IEvent ()=default
 Virtual destructor.
 

Private Attributes

Status _status
 Connection status.
 
std::string _message
 Optional status message.
 

Detailed Description

Event representing a connection state change.

ConnectionEvent signals changes in the client-server connection:

  • Successfully connected to server
  • Disconnected from server
  • Connection failed

Published by Replicator when connection state changes. Subscribed by UI systems to show connection status.

Note
Contains optional error message for failed connections

Definition at line 118 of file NetworkEvent.hpp.

Member Enumeration Documentation

◆ Status

enum class ConnectionEvent::Status
strong

Connection status states.

Enumerator
CONNECTED 

Successfully connected to server.

DISCONNECTED 

Disconnected from server.

FAILED 

Connection attempt failed.

Definition at line 124 of file NetworkEvent.hpp.

Constructor & Destructor Documentation

◆ ConnectionEvent()

ConnectionEvent::ConnectionEvent ( Status  status,
const std::string &  message = "" 
)
inlineexplicit

Construct a connection event.

Parameters
statusConnection status
messageOptional status message (e.g., error description)

Definition at line 136 of file NetworkEvent.hpp.

Member Function Documentation

◆ getMessage()

const std::string & ConnectionEvent::getMessage ( ) const
inline

Get the status message.

Returns
Optional message (empty if no message)

Definition at line 149 of file NetworkEvent.hpp.

References _message.

◆ getStatus()

Status ConnectionEvent::getStatus ( ) const
inline

Get the connection status.

Returns
Current connection status

Definition at line 143 of file NetworkEvent.hpp.

References _status.

Member Data Documentation

◆ _message

std::string ConnectionEvent::_message
private

Optional status message.

Definition at line 153 of file NetworkEvent.hpp.

Referenced by getMessage().

◆ _status

Status ConnectionEvent::_status
private

Connection status.

Definition at line 152 of file NetworkEvent.hpp.

Referenced by getStatus().


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