private static void SendSerializedData(CacheNotifyData[] originalNotifyData, List <byte[]> serializedData, UdpCacheNotifierTargetCollection targets) { Logger logger = null; try { logger = LoggerFactory.Create("UdpCache"); } catch (SystemSupportException) { } for (int i = 0; i < originalNotifyData.Length; i++) { byte[] data = serializedData[i]; CacheNotifyData notifyData = originalNotifyData[i]; foreach (UdpCacheNotifierTarget endPoint in targets) { foreach (int port in endPoint.GetPorts()) { using (UdpClient udp = new UdpClient()) { IPEndPoint remoteEndPoint = new IPEndPoint(endPoint.Address, port); udp.Connect(remoteEndPoint); udp.Send(data, data.Length); } } if (logger != null) { logger.Write(CreateLogEntity(notifyData, endPoint)); } } UdpCacheNotifier.TotalCounters.UdpSentItemsCounter.Increment(); UdpCacheNotifier.TotalCounters.UdpSentCountPerSecond.Increment(); UdpCacheNotifier.AppInstanceCounters.UdpSentItemsCounter.Increment(); UdpCacheNotifier.AppInstanceCounters.UdpSentCountPerSecond.Increment(); } }
public SendDataWrapper(CacheNotifyData[] originalNotifyData, List <byte[]> dl, UdpCacheNotifierTargetCollection t) { OriginalNotifyData = originalNotifyData; DataList = dl; Targets = t; }