mirror of
https://github.com/ChuXunYu/OnlineRpg.git
synced 2026-01-31 11:55:46 +00:00
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include <memory>
|
|
|
|
// 前向声明
|
|
class GameServer;
|
|
|
|
/**
|
|
* @brief 游戏大厅管理类
|
|
*
|
|
* 功能:
|
|
* 1. 管理大厅聊天
|
|
* 2. 处理玩家列表
|
|
* 3. 处理对战邀请
|
|
*/
|
|
class GameLobby {
|
|
private:
|
|
GameServer* m_server;
|
|
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
*/
|
|
explicit GameLobby(GameServer* server);
|
|
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
~GameLobby();
|
|
|
|
/**
|
|
* @brief 广播聊天消息
|
|
* @param sender 发送者用户名
|
|
* @param message 消息内容
|
|
* @param excludeClientId 排除的客户端ID (不发送给自己)
|
|
*/
|
|
void broadcastMessage(const std::string& sender,
|
|
const std::string& message,
|
|
int excludeClientId = -1);
|
|
|
|
/**
|
|
* @brief 处理对战邀请
|
|
* @param inviter 邀请者用户名
|
|
* @param target 被邀请者用户名
|
|
* @return bool 是否成功发送邀请
|
|
*/
|
|
bool handleInvite(const std::string& inviter, const std::string& target);
|
|
|
|
/**
|
|
* @brief 处理邀请响应
|
|
* @param inviter 邀请者用户名
|
|
* @param target 被邀请者用户名
|
|
* @param accept 是否接受
|
|
* @return bool 是否成功处理
|
|
*/
|
|
bool handleInviteResponse(const std::string& inviter,
|
|
const std::string& target,
|
|
bool accept);
|
|
};
|