Skip to content

Commit 600b00b

Browse files
committed
okay actually do make copy
1 parent 35cb05b commit 600b00b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

SteamTransport/Server.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Steamworks;
33
using System;
44
using System.Collections.Generic;
5+
using System.Linq;
56

67
namespace SteamTransport;
78

@@ -102,7 +103,8 @@ public void Receive()
102103
{
103104
var ppOutMessages = new IntPtr[Util.MaxMessages];
104105

105-
foreach (var conn in _conns)
106+
// receive can result in disconnect, which modifies the collection. we must copy
107+
foreach (var conn in _conns.ToList())
106108
{
107109
var numMessages = SteamNetworkingSockets.ReceiveMessagesOnConnection(conn, ppOutMessages, ppOutMessages.Length);
108110
for (var i = 0; i < numMessages; i++)

0 commit comments

Comments
 (0)