23 lines
483 B
C
23 lines
483 B
C
|
#ifndef __CHATROOM_H__
|
||
|
#define __CHATROOM_H__
|
||
|
|
||
|
#include "Singleton.h"
|
||
|
#include <mutex>
|
||
|
#include <unordered_set>
|
||
|
|
||
|
class WebSocketSession;
|
||
|
|
||
|
class ChatRoom {
|
||
|
public:
|
||
|
void join(WebSocketSession *session);
|
||
|
void leave(WebSocketSession *session);
|
||
|
/**
|
||
|
* @brief Broadcast a message to all websocket client sessions
|
||
|
*/
|
||
|
void send(std::string message);
|
||
|
|
||
|
private:
|
||
|
std::mutex m_mutex;
|
||
|
std::unordered_set<WebSocketSession *> m_sessions;
|
||
|
};
|
||
|
#endif // __CHATROOM_H__
|