-
Notifications
You must be signed in to change notification settings - Fork 1
/
MessageCore.h
53 lines (41 loc) · 1.04 KB
/
MessageCore.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef _RAIN_MESSAGECORE_H
#define _RAIN_MESSAGECORE_H
#include <wx/wx.h>
#include <map>
#include <vector>
#include "RainSandboxApp.h"
#define QUIETNESS_THRESHOLD 5
namespace RAIN
{
class SandboxApp;
class Message;
class MessageHandler;
class MeshCore;
enum MSG_PRIORITY
{
MSG_PRIORITY_NORMAL,
MSG_PRIORITY_LOW
};
class MessageCore
{
public:
MessageCore(RAIN::SandboxApp *app);
~MessageCore();
void PushMessage(RAIN::Message *msg, MSG_PRIORITY priority = MSG_PRIORITY_NORMAL);
void Pump();
void HandleMessage(RAIN::Message *msg);
/* registering message handlers */
bool RegisterMessageHandler(RAIN::MessageHandler *hdlr);
bool HasSeenSerial(const wxString &ser);
RAIN::SandboxApp *app;
private:
int quietness;
wxMutex messageQueueMutex;
wxMutex messagelpQueueMutex;
std::vector<RAIN::Message*> queue;
std::vector<RAIN::Message*> lpQueue;
std::vector<wxString> seenSerials;
std::map<int, RAIN::MessageHandler*> handlers;
};
};
#endif//_RAIN_MESSAGECORE_H