Remove Connections only from a queue to prevent desync
This commit is contained in:
parent
6ba89572ae
commit
8d2e90a457
@ -15,6 +15,7 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
|
|||||||
private Peer Peer;
|
private Peer Peer;
|
||||||
|
|
||||||
public Dictionary<ulong, Queue<ProtocolAction>> ProtocolActionQueues = new Dictionary<ulong, Queue<ProtocolAction>>();
|
public Dictionary<ulong, Queue<ProtocolAction>> ProtocolActionQueues = new Dictionary<ulong, Queue<ProtocolAction>>();
|
||||||
|
private Queue<Connection> ConnectionsToRemove = new Queue<Connection>();
|
||||||
|
|
||||||
private Thread UpdateThread;
|
private Thread UpdateThread;
|
||||||
|
|
||||||
@ -131,6 +132,10 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (ConnectionsToRemove.Count > 0) {
|
||||||
|
Connection conn = ConnectionsToRemove.Dequeue();
|
||||||
|
RemoveConnection(conn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddConnection(Connection conn) {
|
private void AddConnection(Connection conn) {
|
||||||
@ -257,7 +262,7 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
|
|||||||
}
|
}
|
||||||
foreach (ulong uid in timedOut) {
|
foreach (ulong uid in timedOut) {
|
||||||
Connection conn = Connections[uid];
|
Connection conn = Connections[uid];
|
||||||
RemoveConnection(conn);
|
ConnectionsToRemove.Enqueue(conn);
|
||||||
if (conn.Status == ConnectionStatus.Ready
|
if (conn.Status == ConnectionStatus.Ready
|
||||||
|| conn.Status == ConnectionStatus.Establishing
|
|| conn.Status == ConnectionStatus.Establishing
|
||||||
|| conn.Status == ConnectionStatus.Awaiting
|
|| conn.Status == ConnectionStatus.Awaiting
|
||||||
|
Loading…
Reference in New Issue
Block a user