Exemple #1
0
        private void Deliver(NecClient sender, ChatResponse chatResponse)
        {
            switch (chatResponse.MessageType)
            {
            case ChatMessageType.ChatCommand:
                chatResponse.Recipients.Add(sender);
                break;

            case ChatMessageType.All:
                chatResponse.Recipients.AddRange(sender.Map.ClientLookup.GetAll());
                break;

            case ChatMessageType.Area:
                chatResponse.Recipients.AddRange(sender.Map.ClientLookup.GetAll());
                break;

            case ChatMessageType.Shout:
                chatResponse.Recipients.AddRange(sender.Map.ClientLookup.GetAll());
                break;

            case ChatMessageType.Whisper:
                NecClient recipient = _server.Clients.GetBySoulName(chatResponse.RecipientSoulName);
                if (recipient == null)
                {
                    Logger.Error($"SoulName: {chatResponse.RecipientSoulName} not found");
                    return;
                }

                chatResponse.Recipients.Add(sender);
                chatResponse.Recipients.Add(recipient);
                break;

            default:
                chatResponse.Recipients.Add(sender);
                break;
            }

            _server.Router.Send(chatResponse);
        }
Exemple #2
0
        public void Handle(NecClient client, ChatMessage message)
        {
            if (client == null)
            {
                Logger.Debug("Client is Null");
                return;
            }

            if (message == null)
            {
                Logger.Debug(client, "Chat Message is Null");
                return;
            }

            ChatResponse response =
                new ChatResponse(client, message.Message, message.MessageType, message.RecipientSoulName);
            List <ChatResponse> responses = new List <ChatResponse>();

            foreach (IChatHandler handler in _handler)
            {
                handler.Handle(client, message, response, responses);
            }

            if (!response.Deliver)
            {
                RespondPostMessage(client, ChatErrorType.GenericUnknownStatement);
                return;
            }

            Deliver(client, response);
            RespondPostMessage(client, ChatErrorType.Success);


            foreach (ChatResponse chatResponse in responses)
            {
                Deliver(client, chatResponse);
            }
        }
Exemple #3
0
 public abstract void Handle(NecClient client, ChatMessage message, ChatResponse response,
                             List <ChatResponse> responses);