Compare commits
No commits in common. "45610f7b19ebe2c200fbbf0b2e0a0629f79d51e6" and "952c29051fcadb980def31f33d96c9dc4b75b664" have entirely different histories.
45610f7b19
...
952c29051f
|
@ -9,7 +9,7 @@ namespace InnovEnergy.App.SaliMax.MiddlewareClasses;
|
|||
|
||||
public static class MiddlewareAgent
|
||||
{
|
||||
private static UdpClient _udpListener = null!;
|
||||
public static UdpClient UdpListener = null!;
|
||||
private static IPAddress? _controllerIpAddress;
|
||||
private static EndPoint? _endPoint;
|
||||
|
||||
|
@ -24,9 +24,9 @@ public static class MiddlewareAgent
|
|||
const Int32 udpPort = 9000;
|
||||
_endPoint = new IPEndPoint(_controllerIpAddress, udpPort);
|
||||
|
||||
_udpListener = new UdpClient();
|
||||
_udpListener.Client.Blocking = false;
|
||||
_udpListener.Client.Bind(_endPoint);
|
||||
UdpListener = new UdpClient();
|
||||
UdpListener.Client.Blocking = false;
|
||||
UdpListener.Client.Bind(_endPoint);
|
||||
}
|
||||
|
||||
private static IPAddress FindVpnIp()
|
||||
|
@ -53,7 +53,7 @@ public static class MiddlewareAgent
|
|||
|
||||
public static Configuration? SetConfigurationFile()
|
||||
{
|
||||
if (_udpListener.Available > 0)
|
||||
if (UdpListener.Available > 0)
|
||||
{
|
||||
|
||||
IPEndPoint? serverEndpoint = null;
|
||||
|
@ -61,7 +61,7 @@ public static class MiddlewareAgent
|
|||
var replyMessage = "ACK";
|
||||
var replyData = Encoding.UTF8.GetBytes(replyMessage);
|
||||
|
||||
var udpMessage = _udpListener.Receive(ref serverEndpoint);
|
||||
var udpMessage = UdpListener.Receive(ref serverEndpoint);
|
||||
var message = Encoding.UTF8.GetString(udpMessage);
|
||||
|
||||
var config = JsonSerializer.Deserialize<Configuration>(message);
|
||||
|
@ -74,13 +74,13 @@ public static class MiddlewareAgent
|
|||
config.CalibrationChargeDate);
|
||||
|
||||
// Send the reply to the sender's endpoint
|
||||
_udpListener.Send(replyData, replyData.Length, serverEndpoint);
|
||||
UdpListener.Send(replyData, replyData.Length, serverEndpoint);
|
||||
Console.WriteLine($"Replied to {serverEndpoint}: {replyMessage}");
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
if (_endPoint != null && !_endPoint.Equals(_udpListener.Client.LocalEndPoint as IPEndPoint))
|
||||
if (_endPoint != null && !_endPoint.Equals(UdpListener.Client.LocalEndPoint as IPEndPoint))
|
||||
{
|
||||
Console.WriteLine("UDP address has changed, rebinding...");
|
||||
InitializeCommunicationToMiddleware();
|
||||
|
|
Loading…
Reference in New Issue