// // Licensed under the MIT License. See LICENSE file in the project root for full license information. // namespace MUnique.OpenMU.GameServer.RemoteView; using System.Runtime.InteropServices; using MUnique.OpenMU.GameLogic.Views; using MUnique.OpenMU.Network.Packets.ServerToClient; using MUnique.OpenMU.PlugIns; /// /// The default implementation of the chat view which is forwarding everything to the game client which specific data packets. /// [PlugIn] [Display(Name = nameof(PlugInResources.ChatViewPlugIn_Name), Description = nameof(PlugInResources.ChatViewPlugIn_Description), ResourceType = typeof(PlugInResources))] [Guid("F0B5BAD4-B97C-49F1-84E0-25EDC796B0E4")] public class ChatViewPlugIn : IChatViewPlugIn { private readonly RemotePlayer _player; /// /// Initializes a new instance of the class. /// /// The player. public ChatViewPlugIn(RemotePlayer player) { this._player = player; } /// public async ValueTask ChatMessageAsync(string message, string sender, ChatMessageType type) { await this._player.Connection.SendChatMessageAsync(ConvertChatMessageType(type), sender, message).ConfigureAwait(false); } private static ChatMessage.ChatMessageType ConvertChatMessageType(ChatMessageType type) { if (type == ChatMessageType.Whisper) { return Network.Packets.ServerToClient.ChatMessage.ChatMessageType.Whisper; } return Network.Packets.ServerToClient.ChatMessage.ChatMessageType.Normal; } }