Added character limit for chat (#1586)
* Added character limit for chat * Changed buffer reading from Int16 to Int32 Co-authored-by: Clément <clement.orlandini@gmail.com>
This commit is contained in:
39
Content.Shared/Chat/ChatMaxMsgLengthMessage.cs
Normal file
39
Content.Shared/Chat/ChatMaxMsgLengthMessage.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.Network;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Content.Shared.Chat
|
||||
{
|
||||
/// <summary>
|
||||
/// This message is sent by the server to let clients know what is the chat's character limit for this server.
|
||||
/// It is first sent by the client as a request
|
||||
/// </summary>
|
||||
public sealed class ChatMaxMsgLengthMessage : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(ChatMaxMsgLengthMessage);
|
||||
public ChatMaxMsgLengthMessage(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The max length a player-sent message can get
|
||||
/// </summary>
|
||||
public int MaxMessageLength { get; set; }
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
MaxMessageLength = buffer.ReadInt32();
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
buffer.Write(MaxMessageLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user