summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/network/CMakeLists.txt6
-rw-r--r--src/network/announce_multiplayer_session.cpp (renamed from src/core/announce_multiplayer_session.cpp)0
-rw-r--r--src/network/announce_multiplayer_session.h (renamed from src/core/announce_multiplayer_session.h)0
-rw-r--r--src/network/room.cpp14
-rw-r--r--src/network/room_member.cpp6
-rw-r--r--src/network/room_member.h2
6 files changed, 20 insertions, 8 deletions
diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt
index 312f79b68..6f8ca4b90 100644
--- a/src/network/CMakeLists.txt
+++ b/src/network/CMakeLists.txt
@@ -2,6 +2,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later
add_library(network STATIC
+ announce_multiplayer_session.cpp
+ announce_multiplayer_session.h
network.cpp
network.h
packet.cpp
@@ -17,3 +19,7 @@ add_library(network STATIC
create_target_directory_groups(network)
target_link_libraries(network PRIVATE common enet Boost::boost)
+if (ENABLE_WEB_SERVICE)
+ target_compile_definitions(network PRIVATE -DENABLE_WEB_SERVICE)
+ target_link_libraries(network PRIVATE web_service)
+endif()
diff --git a/src/core/announce_multiplayer_session.cpp b/src/network/announce_multiplayer_session.cpp
index 6737ce85a..6737ce85a 100644
--- a/src/core/announce_multiplayer_session.cpp
+++ b/src/network/announce_multiplayer_session.cpp
diff --git a/src/core/announce_multiplayer_session.h b/src/network/announce_multiplayer_session.h
index db790f7d2..db790f7d2 100644
--- a/src/core/announce_multiplayer_session.h
+++ b/src/network/announce_multiplayer_session.h
diff --git a/src/network/room.cpp b/src/network/room.cpp
index b06797bf1..8c63b255b 100644
--- a/src/network/room.cpp
+++ b/src/network/room.cpp
@@ -221,7 +221,7 @@ public:
* Extracts the game name from a received ENet packet and broadcasts it.
* @param event The ENet event that was received.
*/
- void HandleGameNamePacket(const ENetEvent* event);
+ void HandleGameInfoPacket(const ENetEvent* event);
/**
* Removes the client from the members list if it was in it and announces the change
@@ -234,7 +234,7 @@ public:
void Room::RoomImpl::ServerLoop() {
while (state != State::Closed) {
ENetEvent event;
- if (enet_host_service(server, &event, 50) > 0) {
+ if (enet_host_service(server, &event, 5) > 0) {
switch (event.type) {
case ENET_EVENT_TYPE_RECEIVE:
switch (event.packet->data[0]) {
@@ -242,7 +242,7 @@ void Room::RoomImpl::ServerLoop() {
HandleJoinRequest(&event);
break;
case IdSetGameInfo:
- HandleGameNamePacket(&event);
+ HandleGameInfoPacket(&event);
break;
case IdProxyPacket:
HandleProxyPacket(&event);
@@ -778,6 +778,7 @@ void Room::RoomImpl::BroadcastRoomInformation() {
packet.Write(member.fake_ip);
packet.Write(member.game_info.name);
packet.Write(member.game_info.id);
+ packet.Write(member.game_info.version);
packet.Write(member.user_data.username);
packet.Write(member.user_data.display_name);
packet.Write(member.user_data.avatar_url);
@@ -817,6 +818,7 @@ void Room::RoomImpl::HandleProxyPacket(const ENetEvent* event) {
in_packet.IgnoreBytes(sizeof(u16)); // Port
in_packet.IgnoreBytes(sizeof(u8)); // Protocol
+
bool broadcast;
in_packet.Read(broadcast); // Broadcast
@@ -909,7 +911,7 @@ void Room::RoomImpl::HandleChatPacket(const ENetEvent* event) {
}
}
-void Room::RoomImpl::HandleGameNamePacket(const ENetEvent* event) {
+void Room::RoomImpl::HandleGameInfoPacket(const ENetEvent* event) {
Packet in_packet;
in_packet.Append(event->packet->data, event->packet->dataLength);
@@ -917,6 +919,7 @@ void Room::RoomImpl::HandleGameNamePacket(const ENetEvent* event) {
GameInfo game_info;
in_packet.Read(game_info.name);
in_packet.Read(game_info.id);
+ in_packet.Read(game_info.version);
{
std::lock_guard lock(member_mutex);
@@ -935,7 +938,8 @@ void Room::RoomImpl::HandleGameNamePacket(const ENetEvent* event) {
if (game_info.name.empty()) {
LOG_INFO(Network, "{} is not playing", display_name);
} else {
- LOG_INFO(Network, "{} is playing {}", display_name, game_info.name);
+ LOG_INFO(Network, "{} is playing {} ({})", display_name, game_info.name,
+ game_info.version);
}
}
}
diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp
index 9f08bf611..06818af78 100644
--- a/src/network/room_member.cpp
+++ b/src/network/room_member.cpp
@@ -103,7 +103,7 @@ public:
/**
* Extracts a ProxyPacket from a received ENet packet.
- * @param event The ENet event that was received.
+ * @param event The ENet event that was received.
*/
void HandleProxyPackets(const ENetEvent* event);
@@ -159,7 +159,7 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
while (IsConnected()) {
std::lock_guard lock(network_mutex);
ENetEvent event;
- if (enet_host_service(client, &event, 100) > 0) {
+ if (enet_host_service(client, &event, 5) > 0) {
switch (event.type) {
case ENET_EVENT_TYPE_RECEIVE:
switch (event.packet->data[0]) {
@@ -315,6 +315,7 @@ void RoomMember::RoomMemberImpl::HandleRoomInformationPacket(const ENetEvent* ev
packet.Read(member.fake_ip);
packet.Read(member.game_info.name);
packet.Read(member.game_info.id);
+ packet.Read(member.game_info.version);
packet.Read(member.username);
packet.Read(member.display_name);
packet.Read(member.avatar_url);
@@ -622,6 +623,7 @@ void RoomMember::SendGameInfo(const GameInfo& game_info) {
packet.Write(static_cast<u8>(IdSetGameInfo));
packet.Write(game_info.name);
packet.Write(game_info.id);
+ packet.Write(game_info.version);
room_member_impl->Send(std::move(packet));
}
diff --git a/src/network/room_member.h b/src/network/room_member.h
index 4252b7146..f578f7f6a 100644
--- a/src/network/room_member.h
+++ b/src/network/room_member.h
@@ -146,7 +146,7 @@ public:
const std::string& password = "", const std::string& token = "");
/**
- * Sends a WiFi packet to the room.
+ * Sends a Proxy packet to the room.
* @param packet The WiFi packet to send.
*/
void SendProxyPacket(const ProxyPacket& packet);