룸 내의 유저만 조회 기능 추가

This commit is contained in:
2025-05-10 17:40:58 +09:00
parent 91a3cfd9f4
commit 7c382bead0
5 changed files with 131 additions and 21 deletions

View File

@@ -12,6 +12,7 @@ enum class PacketSet {
ROOMJOINREQUEST,
ROOMEXITREQUEST,
USERSLISTREQUEST,
ROOMUSERSLISTREQUEST,
DATAPOST,
CONTINUE,
RESPONSE,
@@ -21,6 +22,7 @@ enum class PacketSet {
ROOMJOINRESPONSE,
ROOMEXITRESPONSE,
USERSLISTRESPONSE,
ROOMUSERSLISTRESPONSE,
INVALID
};
@@ -38,6 +40,7 @@ enum class RequestType : std::uint8_t {
ROOM_JOIN,
ROOM_EXIT,
USERS_LIST,
ROOM_USERS_LIST,
DATA
};
@@ -142,6 +145,35 @@ public:
class alignas(4) UsersListRequestPacket : public Packet {};
class alignas(4) RoomUsersListRequestPacket : public Packet {
public:
union {
struct {
PacketCategory packetType;
RequestType requestType;
DataType dataType;
std::uint16_t packetLength;
std::uint16_t roomId[4];
std::uint8_t data[];
} __data;
std::uint8_t serialized[1500] = "";
};
std::uint8_t* convToN() {
__data.packetLength = ::htons(__data.packetLength);
for (int i = 0; i < 4; i++) {
__data.roomId[i] = ::htons(__data.roomId[i]);
}
return serialized;
}
std::uint8_t* convToH() {
__data.packetLength = ::ntohs(__data.packetLength);
for (int i = 0; i < 4; i++) {
__data.roomId[i] = ::ntohs(__data.roomId[i]);
}
return serialized;
}
};
class alignas(4) DataPostPacket : public Packet {
public:
union {