File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/application/setups/server Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ class webrtc_server_detail {
128
128
129
129
/* We need this since yojimbo can only identify clients by slot (port) */
130
130
std::unordered_map<std::string, client_id> id_map;
131
+ client_id next_client_id = 0 ;
131
132
132
133
auto set_this_server_id (const std::string& new_id) {
133
134
std::scoped_lock lk (this_server_id_lk);
@@ -142,8 +143,11 @@ class webrtc_server_detail {
142
143
143
144
client_id assign_client_id () {
144
145
for (client_id i = 0 ; i < max_clients; ++i) {
145
- if (pcs.find (i) == pcs.end ()) {
146
- return i;
146
+ 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;
147
151
}
148
152
}
149
153
You can’t perform that action at this time.
0 commit comments