Skip to content
This repository has been archived by the owner on May 1, 2018. It is now read-only.

Commit

Permalink
[messages]: add class Types
Browse files Browse the repository at this point in the history
  • Loading branch information
loktionov129 committed Jan 5, 2018
1 parent 5d1ce9f commit 14caf1e
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 47 deletions.
2 changes: 1 addition & 1 deletion WebSocketServer/Messages/Handlers/AuthHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace WebSocketServer.Messages.Handlers
public class AuthHandler : BaseHandler
{
/// <inheritdoc />
protected override string Target => Payloads.Server.AuthMessage.Type;
protected override string Target => Payloads.Types.AuthMessage;

/// <inheritdoc />
public override bool CanHandle(IWebSocketConnection socket, string messageType, IServer server)
Expand Down
2 changes: 1 addition & 1 deletion WebSocketServer/Messages/Handlers/ChatHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace WebSocketServer.Messages.Handlers
public class ChatHandler : BaseHandler
{
/// <inheritdoc />
protected override string Target => Payloads.Server.ChatMessage.Type;
protected override string Target => Payloads.Types.ChatMessage;

/// <inheritdoc />
public override void Handle(IWebSocketConnection socket, string webSocketMessage, IServer server)
Expand Down
2 changes: 1 addition & 1 deletion WebSocketServer/Messages/Handlers/UsersListHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace WebSocketServer.Messages.Handlers
public class UsersListHandler : BaseHandler
{
/// <inheritdoc />
protected override string Target => Payloads.Server.UsersListMessage.Type;
protected override string Target => Payloads.Types.UsersListMessage;

/// <inheritdoc />
public override void Handle(IWebSocketConnection socket, string webSocketMessage, IServer server)
Expand Down
2 changes: 1 addition & 1 deletion WebSocketServer/Messages/Payloads/BaseMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace WebSocketServer.Messages.Payloads
/// <summary>
/// The base message.
/// </summary>
public class BaseMessage
public abstract class BaseMessage
{
/// <summary>
/// Gets the message type.
Expand Down
9 changes: 2 additions & 7 deletions WebSocketServer/Messages/Payloads/Client/AuthMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@
namespace WebSocketServer.Messages.Payloads.Client
{
/// <inheritdoc />
public partial class AuthMessage : BaseMessage
public class AuthMessage : BaseMessage
{
/// <summary>
/// Тип сообщения.
/// </summary>
public const string Type = "AUTH_MESSAGE";

/// <summary>
/// Gets or sets the user name.
/// </summary>
public string UserName { get; set; }

/// <inheritdoc />
protected override string MessageType => Type;
protected override string MessageType => Types.AuthMessage;
}
}
7 changes: 1 addition & 6 deletions WebSocketServer/Messages/Payloads/Client/ChatMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ namespace WebSocketServer.Messages.Payloads.Client
/// <inheritdoc />
public class ChatMessage : BaseMessage
{
/// <summary>
/// The type.
/// </summary>
public const string Type = "CHAT_MESSAGE";

/// <summary>
/// Gets or sets the message.
/// </summary>
public string Message { get; set; }

/// <inheritdoc />
protected override string MessageType => Type;
protected override string MessageType => Types.ChatMessage;
}
}
7 changes: 1 addition & 6 deletions WebSocketServer/Messages/Payloads/Client/UsersListMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ namespace WebSocketServer.Messages.Payloads.Client
/// <inheritdoc />
public class UsersListMessage : BaseMessage
{
/// <summary>
/// Тип сообщения.
/// </summary>
public const string Type = "USERS_LIST_MESSAGE";

/// <inheritdoc />
protected override string MessageType => Type;
protected override string MessageType => Types.UsersListMessage;
}
}
7 changes: 1 addition & 6 deletions WebSocketServer/Messages/Payloads/Server/AuthMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ namespace WebSocketServer.Messages.Payloads.Server
/// <inheritdoc />
public partial class AuthMessage : BaseMessage
{
/// <summary>
/// Тип сообщения.
/// </summary>
public const string Type = "AUTH_MESSAGE";

/// <summary>
/// Текст сообщения об успешной или неудачной авторизации.
/// </summary>
Expand All @@ -33,6 +28,6 @@ public partial class AuthMessage : BaseMessage
public string UserName { get; set; }

/// <inheritdoc />
protected override string MessageType => Type;
protected override string MessageType => Types.AuthMessage;
}
}
7 changes: 1 addition & 6 deletions WebSocketServer/Messages/Payloads/Server/ChatMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ namespace WebSocketServer.Messages.Payloads.Server
/// <inheritdoc />
public class ChatMessage : BaseMessage
{
/// <summary>
/// The type.
/// </summary>
public const string Type = "CHAT_MESSAGE";

/// <summary>
/// Gets or sets the message.
/// </summary>
Expand All @@ -33,6 +28,6 @@ public class ChatMessage : BaseMessage
public string UserName { get; set; }

/// <inheritdoc />
protected override string MessageType => Type;
protected override string MessageType => Types.ChatMessage;
}
}
7 changes: 1 addition & 6 deletions WebSocketServer/Messages/Payloads/Server/InvalidMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ namespace WebSocketServer.Messages.Payloads.Server
/// <inheritdoc />
public class InvalidMessage : BaseMessage
{
/// <summary>
/// Тип сообщения.
/// </summary>
public const string Type = "INVALID_MESSAGE";

/// <summary>
/// Сообщение об ошибке.
/// </summary>
public string Message { get; set; }

/// <inheritdoc />
protected override string MessageType => Type;
protected override string MessageType => Types.InvalidMessage;
}
}
7 changes: 1 addition & 6 deletions WebSocketServer/Messages/Payloads/Server/UsersListMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ namespace WebSocketServer.Messages.Payloads.Server
/// <inheritdoc />
public class UsersListMessage : BaseMessage
{
/// <summary>
/// Тип сообщения.
/// </summary>
public const string Type = "USERS_LIST_MESSAGE";

/// <summary>
/// Список пользователей онлайн.
/// </summary>
public string[] UsersList { get; set; }

/// <inheritdoc />
protected override string MessageType => Type;
protected override string MessageType => Types.UsersListMessage;
}
}
37 changes: 37 additions & 0 deletions WebSocketServer/Messages/Payloads/Types.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Types.cs" company="mpgp">
// Multiplayer Game Platform
// </copyright>
// <summary>
// Defines the Types of Messages.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WebSocketServer.Messages.Payloads
{
/// <summary>
/// The types of messages.
/// </summary>
public static class Types
{
/// <summary>
/// The auth message.
/// </summary>
public static readonly string AuthMessage = "AUTH_MESSAGE";

/// <summary>
/// The chat message.
/// </summary>
public static readonly string ChatMessage = "CHAT_MESSAGE";

/// <summary>
/// The users list message.
/// </summary>
public static readonly string UsersListMessage = "USERS_LIST_MESSAGE";

/// <summary>
/// The invalid message.
/// </summary>
public static readonly string InvalidMessage = "INVALID_MESSAGE";
}
}
1 change: 1 addition & 0 deletions WebSocketServer/WebSocketServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<Compile Include="Messages\Payloads\Client\UsersListMessage.cs" />
<Compile Include="Messages\Payloads\Server\InvalidMessage.cs" />
<Compile Include="Messages\Payloads\Server\UsersListMessage.cs" />
<Compile Include="Messages\Payloads\Types.cs" />
<Compile Include="Messages\Successor.cs" />
<Compile Include="Messages\Handlers\AuthHandler.cs" />
<Compile Include="Messages\Handlers\BaseHandler.cs" />
Expand Down

0 comments on commit 14caf1e

Please sign in to comment.