Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
chat_interface.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2015 est31 <MTest31@outlook.com>
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation; either version 2.1 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public License along
16with this program; if not, write to the Free Software Foundation, Inc.,
1751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19
20#pragma once
21
22#include "util/container.h"
23#include <string>
24#include <queue>
25#include "irrlichttypes.h"
26
32};
33
34class ChatEvent {
35protected:
36 ChatEvent(ChatEventType a_type) { type = a_type; }
37public:
39};
40
43 u64 a_game_time,
44 u32 a_time) :
46 game_time(a_game_time),
47 time(a_time)
48 {}
49
51 u32 time;
52};
53
54struct ChatEventNick : public ChatEvent {
56 const std::string &a_nick) :
57 ChatEvent(a_type), // one of CET_NICK_ADD, CET_NICK_REMOVE
58 nick(a_nick)
59 {}
60
61 std::string nick;
62};
63
64struct ChatEventChat : public ChatEvent {
65 ChatEventChat(const std::string &a_nick,
66 const std::wstring &an_evt_msg) :
68 nick(a_nick),
69 evt_msg(an_evt_msg)
70 {}
71
72 std::string nick;
73 std::wstring evt_msg;
74};
75
77 MutexedQueue<ChatEvent *> command_queue; // chat backend --> server
78 MutexedQueue<ChatEvent *> outgoing_queue; // server --> chat backend
79};
ChatEventType
Definition: chat_interface.h:27
@ CET_CHAT
Definition: chat_interface.h:28
@ CET_NICK_REMOVE
Definition: chat_interface.h:30
@ CET_TIME_INFO
Definition: chat_interface.h:31
@ CET_NICK_ADD
Definition: chat_interface.h:29
Definition: chat_interface.h:34
ChatEvent(ChatEventType a_type)
Definition: chat_interface.h:36
ChatEventType type
Definition: chat_interface.h:38
Definition: container.h:132
Definition: chat_interface.h:64
std::string nick
Definition: chat_interface.h:72
ChatEventChat(const std::string &a_nick, const std::wstring &an_evt_msg)
Definition: chat_interface.h:65
std::wstring evt_msg
Definition: chat_interface.h:73
Definition: chat_interface.h:54
std::string nick
Definition: chat_interface.h:61
ChatEventNick(ChatEventType a_type, const std::string &a_nick)
Definition: chat_interface.h:55
Definition: chat_interface.h:41
ChatEventTimeInfo(u64 a_game_time, u32 a_time)
Definition: chat_interface.h:42
u64 game_time
Definition: chat_interface.h:50
u32 time
Definition: chat_interface.h:51
Definition: chat_interface.h:76
MutexedQueue< ChatEvent * > command_queue
Definition: chat_interface.h:77
MutexedQueue< ChatEvent * > outgoing_queue
Definition: chat_interface.h:78