using System;
using System.Threading;
using ToolsClassLibrary;
namespace IntelligentControlForsx.Code
{
///
///
///
public static class UdpMassage
{
static UdpHelper udp = new UdpHelper();
static Thread threadServer;
public static void UdpSocketStart()
{
udp.ClientBind();
threadServer = new Thread(recMsg);
threadServer.IsBackground = true;
threadServer.Start();
}
static void recMsg()
{
while (true)
{
byte[] data;
try
{
data = udp.Receive();
}
catch (Exception ex)
{
Console.WriteLine(string.Format("出现异常:{0}", ex.Message));
continue;
}
object dic = JsonHelper.DeSerializeBinary(data);
SocketData udpdata = (SocketData)dic;
foreach (var key in udpdata.FileData.Keys)
{
string sid = key;
double sval =udpdata.FileData[key];
CommunalTarget.UdpDoubleMemory.AddorUpdate(sid, sval);
}
}
}
}
}