ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | List of all members
session_recorder Class Referencefinal

Records communication frames to a session file. More...

#include <session_recorder.hpp>

Collaboration diagram for session_recorder:
Collaboration graph

Public Member Functions

 session_recorder (const session_recorder &)=delete
 
session_recorderoperator= (const session_recorder &)=delete
 
 session_recorder (session_recorder &&)=delete
 
session_recorderoperator= (session_recorder &&)=delete
 
std::expected< std::filesystem::path, session_file_errorstart (const std::filesystem::path &output_directory, const std::string &server_address, messaging::compression_type compression=messaging::compression_type::none)
 Start recording to a new session file.
 
void stop ()
 Stop recording and close the session file.
 
bool is_recording () const
 Check if recording is currently active.
 
void record_sent (const messaging::frame &f)
 Record a frame that was sent by the client.
 
void record_received (const messaging::frame &f)
 Record a frame that was received by the client.
 
boost::uuids::uuid session_id () const
 Get the session ID for the current recording.
 
std::filesystem::path file_path () const
 Get the path to the current recording file.
 
std::uint64_t frame_count () const
 Get the number of frames recorded so far.
 

Detailed Description

Records communication frames to a session file.

This class provides thread-safe recording of frames sent and received during a client session. The recorded data can later be analyzed using the ores.comms.analyser tool.

Usage:

auto result = recorder.start("/path/to/output", "server:8443", compression);
if (result) {
// Recording is active, frames will be written to:
// /path/to/output/session-20250115-143205-abc123.ores
}
// Record frames as they are sent/received
recorder.record_sent(frame);
recorder.record_received(frame);
recorder.stop();
Records communication frames to a session file.
Definition session_recorder.hpp:60
void record_received(const messaging::frame &f)
Record a frame that was received by the client.
Definition session_recorder.cpp:112
void record_sent(const messaging::frame &f)
Record a frame that was sent by the client.
Definition session_recorder.cpp:108
void stop()
Stop recording and close the session file.
Definition session_recorder.cpp:89
std::expected< std::filesystem::path, session_file_error > start(const std::filesystem::path &output_directory, const std::string &server_address, messaging::compression_type compression=messaging::compression_type::none)
Start recording to a new session file.
Definition session_recorder.cpp:36

Member Function Documentation

◆ start()

std::expected< std::filesystem::path, session_file_error > start ( const std::filesystem::path &  output_directory,
const std::string &  server_address,
messaging::compression_type  compression = messaging::compression_type::none 
)

Start recording to a new session file.

Creates a new session file with a unique name in the specified directory. The filename format is: session-YYYYMMDD-HHMMSS-{short-uuid}.ores

Parameters
output_directoryDirectory where the session file will be created
server_addressThe server address being connected to
compressionThe negotiated compression type for the session
Returns
Expected containing the full path to the created file, or error

◆ stop()

void stop ( )

Stop recording and close the session file.

Flushes any buffered data and closes the file. Safe to call multiple times or when not recording.

◆ record_sent()

void record_sent ( const messaging::frame f)

Record a frame that was sent by the client.

Thread-safe. If recording is not active, does nothing.

Parameters
fThe frame that was sent

◆ record_received()

void record_received ( const messaging::frame f)

Record a frame that was received by the client.

Thread-safe. If recording is not active, does nothing.

Parameters
fThe frame that was received

◆ session_id()

boost::uuids::uuid session_id ( ) const

Get the session ID for the current recording.

Returns
The session UUID, or nil UUID if not recording

◆ file_path()

std::filesystem::path file_path ( ) const

Get the path to the current recording file.

Returns
The file path, or empty path if not recording