-
The server is created.
- A
QTcpServerinstance is created. QTcpServer::newConnectionis connected toonNewConnection.
- A
-
On new connection:
- The server retrieves the incoming socket.
- A
ClientContextis created to track:- The client socket
- The client state (e.g. authentication)
ClientContext::messageReceivedis connected toServer::onClientMessage.
-
On client message:
- The server parses the received command into JSON.
- A command factory is used to create the appropriate Command object.
- The command validates the input and checks whether the client is authenticated.
- The command executes its specific functionality.
- Reads the first two arguments.
- Validates client authentication.
- Uses the
QFileclass. - Checks the filename (first argument).
- Creates the file using
open()withQIODevice::WriteOnly.
- Uses the
QFileclass. - Checks the filename (first argument).
- Verifies the file exists.
- Opens the file with truncation.
- Writes the second argument to the file using
QTextStream.
- Uses the
QFileclass. - Checks the filename (first argument).
- Verifies the file exists.
- Opens the file in read-only mode.
- Reads the contents using
QTextStream.
- Same as WRITE.
- Opens the file using the append flag instead of truncation.
- Uses the
QFileclass. - Checks the filename (first argument).
- Verifies the file exists.
- Removes the file using
remove().
- Uses
QDirwith the current path. - Reads directory entries using
entryList().
- Uses the
QFileclass. - Checks the filename (first argument).
- Verifies the file exists.
- Renames the file using
rename().
- Uses the
QFileclass. - Checks the filename (first argument).
- Verifies the file exists.
- Retrieves file information using
QFileInfo.