diff --git a/WebSocketServer/Messages/Handlers/AuthHandler.cs b/WebSocketServer/Messages/Handlers/AuthHandler.cs
index efa9362..ebe351e 100644
--- a/WebSocketServer/Messages/Handlers/AuthHandler.cs
+++ b/WebSocketServer/Messages/Handlers/AuthHandler.cs
@@ -15,7 +15,7 @@ namespace WebSocketServer.Messages.Handlers
public class AuthHandler : BaseHandler
{
///
- protected override string Target => Payloads.Server.AuthMessage.Type;
+ protected override string Target => Payloads.Types.AuthMessage;
///
public override bool CanHandle(IWebSocketConnection socket, string messageType, IServer server)
diff --git a/WebSocketServer/Messages/Handlers/ChatHandler.cs b/WebSocketServer/Messages/Handlers/ChatHandler.cs
index a663d3c..a5df4f5 100644
--- a/WebSocketServer/Messages/Handlers/ChatHandler.cs
+++ b/WebSocketServer/Messages/Handlers/ChatHandler.cs
@@ -15,7 +15,7 @@ namespace WebSocketServer.Messages.Handlers
public class ChatHandler : BaseHandler
{
///
- protected override string Target => Payloads.Server.ChatMessage.Type;
+ protected override string Target => Payloads.Types.ChatMessage;
///
public override void Handle(IWebSocketConnection socket, string webSocketMessage, IServer server)
diff --git a/WebSocketServer/Messages/Handlers/UsersListHandler.cs b/WebSocketServer/Messages/Handlers/UsersListHandler.cs
index f9156f4..d6ff200 100644
--- a/WebSocketServer/Messages/Handlers/UsersListHandler.cs
+++ b/WebSocketServer/Messages/Handlers/UsersListHandler.cs
@@ -16,7 +16,7 @@ namespace WebSocketServer.Messages.Handlers
public class UsersListHandler : BaseHandler
{
///
- protected override string Target => Payloads.Server.UsersListMessage.Type;
+ protected override string Target => Payloads.Types.UsersListMessage;
///
public override void Handle(IWebSocketConnection socket, string webSocketMessage, IServer server)
diff --git a/WebSocketServer/Messages/Payloads/BaseMessage.cs b/WebSocketServer/Messages/Payloads/BaseMessage.cs
index 15b297e..d7d73f7 100644
--- a/WebSocketServer/Messages/Payloads/BaseMessage.cs
+++ b/WebSocketServer/Messages/Payloads/BaseMessage.cs
@@ -12,7 +12,7 @@ namespace WebSocketServer.Messages.Payloads
///
/// The base message.
///
- public class BaseMessage
+ public abstract class BaseMessage
{
///
/// Gets the message type.
diff --git a/WebSocketServer/Messages/Payloads/Client/AuthMessage.cs b/WebSocketServer/Messages/Payloads/Client/AuthMessage.cs
index db00ec7..0617e1b 100644
--- a/WebSocketServer/Messages/Payloads/Client/AuthMessage.cs
+++ b/WebSocketServer/Messages/Payloads/Client/AuthMessage.cs
@@ -10,19 +10,14 @@
namespace WebSocketServer.Messages.Payloads.Client
{
///
- public partial class AuthMessage : BaseMessage
+ public class AuthMessage : BaseMessage
{
- ///
- /// Тип сообщения.
- ///
- public const string Type = "AUTH_MESSAGE";
-
///
/// Gets or sets the user name.
///
public string UserName { get; set; }
///
- protected override string MessageType => Type;
+ protected override string MessageType => Types.AuthMessage;
}
}
diff --git a/WebSocketServer/Messages/Payloads/Client/ChatMessage.cs b/WebSocketServer/Messages/Payloads/Client/ChatMessage.cs
index 418a567..cac560f 100644
--- a/WebSocketServer/Messages/Payloads/Client/ChatMessage.cs
+++ b/WebSocketServer/Messages/Payloads/Client/ChatMessage.cs
@@ -12,17 +12,12 @@ namespace WebSocketServer.Messages.Payloads.Client
///
public class ChatMessage : BaseMessage
{
- ///
- /// The type.
- ///
- public const string Type = "CHAT_MESSAGE";
-
///
/// Gets or sets the message.
///
public string Message { get; set; }
///
- protected override string MessageType => Type;
+ protected override string MessageType => Types.ChatMessage;
}
}
diff --git a/WebSocketServer/Messages/Payloads/Client/UsersListMessage.cs b/WebSocketServer/Messages/Payloads/Client/UsersListMessage.cs
index fc5e08e..b7416b5 100644
--- a/WebSocketServer/Messages/Payloads/Client/UsersListMessage.cs
+++ b/WebSocketServer/Messages/Payloads/Client/UsersListMessage.cs
@@ -12,12 +12,7 @@ namespace WebSocketServer.Messages.Payloads.Client
///
public class UsersListMessage : BaseMessage
{
- ///
- /// Тип сообщения.
- ///
- public const string Type = "USERS_LIST_MESSAGE";
-
///
- protected override string MessageType => Type;
+ protected override string MessageType => Types.UsersListMessage;
}
}
diff --git a/WebSocketServer/Messages/Payloads/Server/AuthMessage.cs b/WebSocketServer/Messages/Payloads/Server/AuthMessage.cs
index e36ee08..c399c30 100644
--- a/WebSocketServer/Messages/Payloads/Server/AuthMessage.cs
+++ b/WebSocketServer/Messages/Payloads/Server/AuthMessage.cs
@@ -12,11 +12,6 @@ namespace WebSocketServer.Messages.Payloads.Server
///
public partial class AuthMessage : BaseMessage
{
- ///
- /// Тип сообщения.
- ///
- public const string Type = "AUTH_MESSAGE";
-
///
/// Текст сообщения об успешной или неудачной авторизации.
///
@@ -33,6 +28,6 @@ public partial class AuthMessage : BaseMessage
public string UserName { get; set; }
///
- protected override string MessageType => Type;
+ protected override string MessageType => Types.AuthMessage;
}
}
diff --git a/WebSocketServer/Messages/Payloads/Server/ChatMessage.cs b/WebSocketServer/Messages/Payloads/Server/ChatMessage.cs
index 3d6b18a..74941da 100644
--- a/WebSocketServer/Messages/Payloads/Server/ChatMessage.cs
+++ b/WebSocketServer/Messages/Payloads/Server/ChatMessage.cs
@@ -12,11 +12,6 @@ namespace WebSocketServer.Messages.Payloads.Server
///
public class ChatMessage : BaseMessage
{
- ///
- /// The type.
- ///
- public const string Type = "CHAT_MESSAGE";
-
///
/// Gets or sets the message.
///
@@ -33,6 +28,6 @@ public class ChatMessage : BaseMessage
public string UserName { get; set; }
///
- protected override string MessageType => Type;
+ protected override string MessageType => Types.ChatMessage;
}
}
diff --git a/WebSocketServer/Messages/Payloads/Server/InvalidMessage.cs b/WebSocketServer/Messages/Payloads/Server/InvalidMessage.cs
index a52e8ca..1fb322b 100644
--- a/WebSocketServer/Messages/Payloads/Server/InvalidMessage.cs
+++ b/WebSocketServer/Messages/Payloads/Server/InvalidMessage.cs
@@ -12,17 +12,12 @@ namespace WebSocketServer.Messages.Payloads.Server
///
public class InvalidMessage : BaseMessage
{
- ///
- /// Тип сообщения.
- ///
- public const string Type = "INVALID_MESSAGE";
-
///
/// Сообщение об ошибке.
///
public string Message { get; set; }
///
- protected override string MessageType => Type;
+ protected override string MessageType => Types.InvalidMessage;
}
}
diff --git a/WebSocketServer/Messages/Payloads/Server/UsersListMessage.cs b/WebSocketServer/Messages/Payloads/Server/UsersListMessage.cs
index f9686ab..9d9c295 100644
--- a/WebSocketServer/Messages/Payloads/Server/UsersListMessage.cs
+++ b/WebSocketServer/Messages/Payloads/Server/UsersListMessage.cs
@@ -12,17 +12,12 @@ namespace WebSocketServer.Messages.Payloads.Server
///
public class UsersListMessage : BaseMessage
{
- ///
- /// Тип сообщения.
- ///
- public const string Type = "USERS_LIST_MESSAGE";
-
///
/// Список пользователей онлайн.
///
public string[] UsersList { get; set; }
///
- protected override string MessageType => Type;
+ protected override string MessageType => Types.UsersListMessage;
}
}
diff --git a/WebSocketServer/Messages/Payloads/Types.cs b/WebSocketServer/Messages/Payloads/Types.cs
new file mode 100644
index 0000000..bf23d78
--- /dev/null
+++ b/WebSocketServer/Messages/Payloads/Types.cs
@@ -0,0 +1,37 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Multiplayer Game Platform
+//
+//
+// Defines the Types of Messages.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace WebSocketServer.Messages.Payloads
+{
+ ///
+ /// The types of messages.
+ ///
+ public static class Types
+ {
+ ///
+ /// The auth message.
+ ///
+ public static readonly string AuthMessage = "AUTH_MESSAGE";
+
+ ///
+ /// The chat message.
+ ///
+ public static readonly string ChatMessage = "CHAT_MESSAGE";
+
+ ///
+ /// The users list message.
+ ///
+ public static readonly string UsersListMessage = "USERS_LIST_MESSAGE";
+
+ ///
+ /// The invalid message.
+ ///
+ public static readonly string InvalidMessage = "INVALID_MESSAGE";
+ }
+}
diff --git a/WebSocketServer/WebSocketServer.csproj b/WebSocketServer/WebSocketServer.csproj
index aeae236..a009c3e 100644
--- a/WebSocketServer/WebSocketServer.csproj
+++ b/WebSocketServer/WebSocketServer.csproj
@@ -56,6 +56,7 @@
+