Older/Server/ChatRoom/ChatRoom.h
2024-01-24 23:19:53 +08:00

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__