Fix new connections adding constantly
This commit is contained in:
parent
88f1a9a8a1
commit
621a37be41
@ -46,5 +46,9 @@ namespace Network {
|
||||
}
|
||||
return Optional<Connection>.None;
|
||||
}
|
||||
|
||||
public Optional<Connection> GetOriginal(string address, int port) {
|
||||
return GetOriginal(new Connection(address, port));
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ using Godot;
|
||||
using Network.PacketHandling;
|
||||
using Network.Syncing;
|
||||
using System.Threading;
|
||||
using Util;
|
||||
using Thread = System.Threading.Thread;
|
||||
|
||||
namespace Network {
|
||||
@ -80,10 +81,13 @@ namespace Network {
|
||||
}
|
||||
|
||||
if (Confirmed) {
|
||||
Connection conn = new Connection(Address, Port);
|
||||
Singleton.ConnectionList.AddConnection(conn);
|
||||
Singleton.PacketDistributor.AddHandler(conn);
|
||||
Singleton.PacketDistributor.HandleRawPacket(PB, Singleton.ConnectionList.GetOriginal(conn));
|
||||
Optional<Connection> Conn = Singleton.ConnectionList.GetOriginal(Address, Port);
|
||||
if (Conn.isEmpty) {
|
||||
Conn = new Connection(Address, Port);
|
||||
Singleton.ConnectionList.AddConnection(Conn);
|
||||
Singleton.PacketDistributor.AddHandler(Conn);
|
||||
}
|
||||
Singleton.PacketDistributor.HandleRawPacket(PB, Singleton.ConnectionList.GetOriginal(Conn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ namespace Network.Syncing {
|
||||
}
|
||||
|
||||
public void Update(float delta) {
|
||||
//GD.print("Update! + " + delta);
|
||||
TimeSinceLastSync += delta;
|
||||
if (TimeSinceLastSync > Interval) {
|
||||
TimeSinceLastSync = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user