We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 697d5d8 commit 2b3ffc6Copy full SHA for 2b3ffc6
src/application/setups/server/server_setup.cpp
@@ -128,6 +128,7 @@ class webrtc_server_detail {
128
129
/* We need this since yojimbo can only identify clients by slot (port) */
130
std::unordered_map<std::string, client_id> id_map;
131
+ client_id next_client_id = 0;
132
133
auto set_this_server_id(const std::string& new_id) {
134
std::scoped_lock lk(this_server_id_lk);
@@ -142,8 +143,11 @@ class webrtc_server_detail {
142
143
144
client_id assign_client_id() {
145
for (client_id i = 0; i < max_clients; ++i) {
- if (pcs.find(i) == pcs.end()) {
146
- return i;
+ const auto id = (next_client_id + i) % max_clients;
147
+
148
+ if (pcs.find(id) == pcs.end()) {
149
+ next_client_id = (id + 1) % max_clients;
150
+ return id;
151
}
152
153
0 commit comments