|
|
@ -68,6 +68,11 @@ public:
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
bool IsValidMacAddress(const MacAddress& address) const;
|
|
|
|
bool IsValidMacAddress(const MacAddress& address) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Sends a ID_ROOM_IS_FULL message telling the client that the room is full.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SendRoomIsFull(ENetPeer* client);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Sends a ID_ROOM_NAME_COLLISION message telling the client that the name is invalid.
|
|
|
|
* Sends a ID_ROOM_NAME_COLLISION message telling the client that the name is invalid.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -193,6 +198,13 @@ void Room::RoomImpl::StartLoop() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) {
|
|
|
|
void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock(member_mutex);
|
|
|
|
|
|
|
|
if (members.size() >= room_information.member_slots) {
|
|
|
|
|
|
|
|
SendRoomIsFull(event->peer);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Packet packet;
|
|
|
|
Packet packet;
|
|
|
|
packet.Append(event->packet->data, event->packet->dataLength);
|
|
|
|
packet.Append(event->packet->data, event->packet->dataLength);
|
|
|
|
packet.IgnoreBytes(sizeof(u8)); // Ignore the message type
|
|
|
|
packet.IgnoreBytes(sizeof(u8)); // Ignore the message type
|
|
|
@ -295,6 +307,16 @@ void Room::RoomImpl::SendWrongPassword(ENetPeer* client) {
|
|
|
|
enet_host_flush(server);
|
|
|
|
enet_host_flush(server);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Room::RoomImpl::SendRoomIsFull(ENetPeer* client) {
|
|
|
|
|
|
|
|
Packet packet;
|
|
|
|
|
|
|
|
packet << static_cast<u8>(IdRoomIsFull);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ENetPacket* enet_packet =
|
|
|
|
|
|
|
|
enet_packet_create(packet.GetData(), packet.GetDataSize(), ENET_PACKET_FLAG_RELIABLE);
|
|
|
|
|
|
|
|
enet_peer_send(client, 0, enet_packet);
|
|
|
|
|
|
|
|
enet_host_flush(server);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Room::RoomImpl::SendVersionMismatch(ENetPeer* client) {
|
|
|
|
void Room::RoomImpl::SendVersionMismatch(ENetPeer* client) {
|
|
|
|
Packet packet;
|
|
|
|
Packet packet;
|
|
|
|
packet << static_cast<u8>(IdVersionMismatch);
|
|
|
|
packet << static_cast<u8>(IdVersionMismatch);
|
|
|
@ -527,7 +549,9 @@ bool Room::Create(const std::string& name, const std::string& server_address, u1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
address.port = server_port;
|
|
|
|
address.port = server_port;
|
|
|
|
|
|
|
|
|
|
|
|
room_impl->server = enet_host_create(&address, max_connections, NumChannels, 0, 0);
|
|
|
|
// In order to send the room is full message to the connecting client, we need to leave one slot
|
|
|
|
|
|
|
|
// open so enet won't reject the incoming connection without telling us
|
|
|
|
|
|
|
|
room_impl->server = enet_host_create(&address, max_connections + 1, NumChannels, 0, 0);
|
|
|
|
if (!room_impl->server) {
|
|
|
|
if (!room_impl->server) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|