Make some neatness updates

This commit is contained in:
Sofia 2020-08-05 17:59:16 +03:00
parent 63eddfa43b
commit 7b426f4f8c
3 changed files with 46 additions and 46 deletions

View File

@ -12,10 +12,9 @@ namespace NeonTea.Quakeball.Net.Peers {
private Peer Peer;
private Thread UpdateThread;
private long LastUpdate;
public long Timeout = 8000;
public long Frequency = 100;
public long Interval = 100;
public ConnectionManager(Peer peer) {
Peer = peer;
@ -159,10 +158,8 @@ namespace NeonTea.Quakeball.Net.Peers {
private void UpdateThreadMethod() {
try {
while (true) {
while (Thread.CurrentThread.IsAlive) {
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
if ((now - LastUpdate) > Frequency) {
LastUpdate = now;
List<KeyValuePair<IPEndPoint, Connection>> timedOut = new List<KeyValuePair<IPEndPoint, Connection>>();
foreach (KeyValuePair<IPEndPoint, Connection> pair in Connections) {
Connection conn = pair.Value;
@ -190,9 +187,9 @@ namespace NeonTea.Quakeball.Net.Peers {
}
}
}
Thread.Sleep((int)Interval);
}
}
} catch (ThreadAbortException e) {
} catch (ThreadAbortException) {
Debug.Log("Connection Thread Stopped");
}
}

View File

@ -44,7 +44,8 @@ namespace NeonTea.Quakeball.Net.Peers {
private void ListenThreadMethod() {
try {
while (true) {
while (Thread.CurrentThread.IsAlive) {
if (Peer.UdpClient.Available > 0) {
IPEndPoint Listened = new IPEndPoint(EndPoint.Address, EndPoint.Port);
ByteBuffer Buffer = new ByteBuffer();
try {
@ -63,7 +64,8 @@ namespace NeonTea.Quakeball.Net.Peers {
Peer.ConnectionManager.Handle(Listened, Buffer);
}
}
} catch (ThreadAbortException e) {
}
} catch (ThreadAbortException) {
Debug.Log("Listener Thread stopped");
}
}

View File

@ -129,6 +129,7 @@ PlayerSettings:
preloadedAssets:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1