Class Utils
Inherited Members
Namespace: EasySave_Project.Server
Assembly: .dll
Syntax
public static class Utils
Methods
| Edit this page View SourceSendToServer(string, NetworkStream)
Sends a message to the server via the provided or default network stream. Ensures the stream is writable before attempting to send data.
Declaration
public static void SendToServer(string message, NetworkStream stream = null)
Parameters
Type | Name | Description |
---|---|---|
string | message | The message to send to the server. |
NetworkStream | stream | An optional network stream; if null, the global client stream is used. |
StartListening(NetworkStream)
Starts listening for incoming messages from the server through the provided network stream. Processes received messages, handles specific commands, and enqueues unknown messages.
Declaration
public static Task StartListening(NetworkStream stream)
Parameters
Type | Name | Description |
---|---|---|
NetworkStream | stream | The network stream used for reading incoming messages. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
WaitForResponse<T>()
Waits for and retrieves a response message from the server, deserializing it into the specified type. Handles JSON parsing errors gracefully.
Declaration
public static Task<T?> WaitForResponse<T>()
Returns
Type | Description |
---|---|
Task<T> | The deserialized response object, or default if parsing fails. |
Type Parameters
Name | Description |
---|---|
T | The expected type of the response object. |