/// <summary> /// Client has send data for the meters that are using the same port. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void OnExclusiveReceived(object sender, Gurux.Common.ReceiveEventArgs e) { try { lock (buffers) { GXByteBuffer bb; if (!buffers.ContainsKey(e.SenderInfo)) { bb = new GXByteBuffer(); buffers[e.SenderInfo] = bb; } else { bb = buffers[e.SenderInfo]; } bb.Set((byte[])e.Data); int target, source; //All simulated meters are using the same interface type. GXDLMSTranslator.GetAddressInfo(interfaceType, bb, out target, out source); if (target != 0 && meters.ContainsKey(target)) { GXDLMSMeter m = meters[target]; if (Trace > TraceLevel.Info) { Console.WriteLine("RX:\t" + Gurux.Common.GXCommon.ToHex((byte[])e.Data, true)); } GXServerReply sr = new GXServerReply(bb.Data); do { m.HandleRequest(sr); //Reply is null if we do not want to send any data to the client. //This is done if client try to make connection with wrong device ID. if (sr.Reply != null) { if (Trace > TraceLevel.Info) { Console.WriteLine("TX:\t" + Gurux.Common.GXCommon.ToHex(sr.Reply, true)); } bb.Clear(); m.Media.Send(sr.Reply, e.SenderInfo); sr.Data = null; } }while (sr.IsStreaming); } } } catch (Exception ex) { if (!(ex is SocketException)) { Console.WriteLine(ex.Message); } } }