diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs
index 371d8e7..95e86e9 100644
--- a/ShiftOS_TheReturn/ServerManager.cs
+++ b/ShiftOS_TheReturn/ServerManager.cs
@@ -39,28 +39,50 @@ using System.Diagnostics;
namespace ShiftOS.Engine
{
+ ///
+ /// Digital Society connection management class.
+ ///
public static class ServerManager
{
+ ///
+ /// Print connection diagnostic information.
+ ///
public static void PrintDiagnostics()
{
Console.WriteLine($@"{{CLIENT_DIAGNOSTICS}}
{{GUID}}: {thisGuid}
+Ping: {ServerManager.DigitalSocietyPing} ms
{{CLIENT_DATA}}:
{JsonConvert.SerializeObject(client, Formatting.Indented)}");
}
+ ///
+ /// Gets the unique identifier for this Digital Society connection. This can be used for peer-to-peer communication between two clients.
+ ///
public static Guid thisGuid { get; private set; }
- private static NetObjectClient client { get; set; }
+
+ ///
+ /// Gets the underlying NetSockets client for this connection.
+ ///
+ public static NetObjectClient client { get; private set; }
+
+
private static bool UserDisconnect = false;
+ ///
+ /// Gets or sets the server response time for the last request made by this client.
+ ///
public static long DigitalSocietyPing
{
get;
private set;
}
+ ///
+ /// Disconnect from the digital society intentionally.
+ ///
public static void Disconnect()
{
UserDisconnect = true;
@@ -72,36 +94,20 @@ namespace ShiftOS.Engine
}
+ ///
+ /// Occurs when you are disconnected from the Digital Society.
+ ///
public static event EmptyEventHandler Disconnected;
-
- public static void InitiateMUDHack()
- {
- MessageReceived += ServerManager_MessageReceived;
- SendMessage("mudhack_init", "");
- }
- public static event Action ServerPasswordGenerated;
- public static event EmptyEventHandler ServerAccessGranted;
- public static event EmptyEventHandler ServerAccessDenied;
+ ///
+ /// Occurs when the unique ID for this client is sent by the server.
+ ///
public static event Action GUIDReceived;
- public static event Action> UsersReceived;
private static void ServerManager_MessageReceived(ServerMessage msg)
{
switch(msg.Name)
{
- case "mudhack_users":
- UsersReceived?.Invoke(JsonConvert.DeserializeObject>(msg.Contents));
- break;
- case "mudhack_init":
- ServerPasswordGenerated?.Invoke(msg.Contents);
- break;
- case "mudhack_denied":
- ServerAccessDenied?.Invoke();
- break;
- case "mudhack_granted":
- ServerAccessGranted?.Invoke();
- break;
case "getguid_fromserver":
if(SaveSystem.CurrentSave.Username == msg.Contents)
{
@@ -124,6 +130,11 @@ namespace ShiftOS.Engine
MessageReceived -= new ServerMessageReceived(ServerManager_MessageReceived);
}
+ ///
+ /// Initiate a new Digital Society connection.
+ ///
+ /// The IP address or hostname of the target server
+ /// The target port.
public static void Initiate(string mud_address, int port)
{
client = new NetObjectClient();
@@ -222,6 +233,11 @@ namespace ShiftOS.Engine
private static Stopwatch PingTimer = new Stopwatch();
+ ///
+ /// Send a message to the server.
+ ///
+ /// The message name
+ /// The message body
public static void SendMessage(string name, string contents)
{
var sMsg = new ServerMessage
@@ -255,21 +271,33 @@ namespace ShiftOS.Engine
}
-
+ ///
+ /// Occurs when the server sends a message to this client.
+ ///
public static event ServerMessageReceived MessageReceived;
- public static void Forward(string targetGUID, string v, string message)
+ ///
+ /// Send a message to another client.
+ ///
+ /// The target client GUID.
+ /// The message title
+ /// The message contents
+ public static void Forward(string targetGUID, string title, string message)
{
var smsg = new ServerMessage
{
GUID = targetGUID,
- Name = v,
+ Name = title,
Contents = message
};
ServerManager.SendMessage("mud_forward", JsonConvert.SerializeObject(smsg));
}
}
+ ///
+ /// Delegate for handling server messages
+ ///
+ /// A server message containing the protocol message name, GUID of the sender, and the contents of the message.
public delegate void ServerMessageReceived(ServerMessage msg);
public class MultiplayerOnlyAttribute : Attribute