Skip to content

Commit

Permalink
fix(natneg): server launch crash
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojiuwo1993 committed Oct 24, 2023
1 parent b386910 commit 548d947
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Libraries/Core/src/Abstraction/BaseClass/ClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected virtual void EventBinding()
break;
case NetworkConnectionType.Udp:
((IUdpConnection)Connection).OnReceive += OnReceived;
_timer = new EasyTimer(TimeSpan.FromHours(1), TimeSpan.FromMinutes(1));
_timer = new EasyTimer(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(1));
_timer.Elapsed += (s, e) => CheckExpiredClient();
_timer.Start();
break;
Expand Down
6 changes: 0 additions & 6 deletions src/Servers/NatNegotiation/src/Application/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ public class Client : ClientBase
public Client(IConnection connection, IServer server) : base(connection, server)
{
Info = new ClientInfo();
_timer = new EasyTimer(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(1));
IsLogRaw = true;
}
protected override ISwitcher CreateSwitcher(object buffer) => new CmdSwitcher(this, (byte[])buffer);
protected override void EventBinding()
{
((IUdpConnection)Connection).OnReceive += OnReceived;
_timer.Elapsed += (s, e) => CheckExpiredClient();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ConnectHandler(Client client, ConnectRequest request) : base(client, requ
protected override void RequestCheck()
{
// detecting nat
var addressInfos = StorageOperation.Persistance.GetInitInfos(_client.Server.Id, (uint)_client.Info.Cookie);
var addressInfos = StorageOperation.Persistance.GetInitInfos(_client.Server.Id, _request.Cookie);
// if (addressInfos.Count < InitHandler.InitPacketCount)
// {
// throw new NatNegotiation.Exception($"The number of init info in redis with cookie: {_client.Info.Cookie} is not bigger than 7.");
Expand Down Expand Up @@ -112,8 +112,8 @@ private void UsingGameRelayServerToNegotiate()
}
//todo the optimized server will be selected
var relayEndPoint = relayServers.OrderBy(x => x.ClientCount).First().PublicIPEndPoint;
var myIPs = _myInitInfo.AddressInfos.Select(x=>x.Value.PublicIPEndPoint.ToString()).ToList();
var otherIPs = _othersInitInfo.AddressInfos.Select(x=>x.Value.PublicIPEndPoint.ToString()).ToList();
var myIPs = _myInitInfo.AddressInfos.Select(x => x.Value.PublicIPEndPoint.ToString()).ToList();
var otherIPs = _othersInitInfo.AddressInfos.Select(x => x.Value.PublicIPEndPoint.ToString()).ToList();
var req = new NatNegotiationRequest()
{
Cookie = _myInitInfo.Cookie,
Expand Down

0 comments on commit 548d947

Please sign in to comment.