/// <summary> /// The init. /// </summary> /// <param name="ipFrom"> /// The ip from. /// </param> /// <param name="uDPListen"> /// The u dp listen. /// </param> /// <param name="beaconPortFrom"> /// The beacon port from. /// </param> /// <param name="tCPListen"> /// The t cp listen. /// </param> /// <param name="uDPSend"> /// The u dp send. /// </param> /// <param name="ipTo"> /// The ip to. /// </param> /// <param name="beaconPortTo"> /// The beacon port to. /// </param> /// <param name="targetIpList"> /// The target ip list. /// </param> /// <param name="rules"> /// The rules. /// </param> private void Init( string ipFrom, int uDPListen, int beaconPortFrom, int tCPListen, int uDPSend, string ipTo, int beaconPortTo, string targetIpList, IRuleSet rules) { this.Rules = rules; this.receiverCodec = new EpicsGateWayReceiverCodec(this); this.connectorCodec = new EpicsGateWayConnectorCodec(this); this.Statistic = new EpicsGateWayStatistics(); // start listening for connection requests on this.tcpListener = new TcpListener(new IPEndPoint(IPAddress.Parse(ipFrom), tCPListen)); this.tcpListener.Start(); this.Config.BeaconPortFrom = beaconPortFrom; this.Config.BeaconPortTo = beaconPortTo; this.Config.TCPListenPort = tCPListen; this.Config.UDPSendPort = uDPSend; this.Config.UDPListenPort = uDPListen; Trace.Write("I" + string.Format("Starting gateway {0}:{1} to ({2}):{3}.", ipFrom, uDPListen, targetIpList, uDPSend)); this.Config.ServerList.Clear(); if (targetIpList.Contains(",")) { var ips = targetIpList.Split(','); foreach (var ip in ips) { this.Config.ServerList.Add(ip + ":" + uDPSend); } } else { this.Config.ServerList.Add(targetIpList + ":" + uDPSend); } // starting a Thread to grab new TCP-Connections and wrap them into a EpicsTCPServerConnection this.connectionGrabber = new Thread(this.GrabConnection); this.connectionGrabber.IsBackground = true; this.connectionGrabber.Start(); this.ChannelSearcher = new Thread(this.HandleChannelSearch); this.ChannelSearcher.IsBackground = true; this.ChannelSearcher.Start(); this.UdpConnFrom = new EpicsUDPGWConnection( this, this.receiverCodec, new IPEndPoint(IPAddress.Parse(ipFrom), this.Config.UDPListenPort)); this.UdpConnTo = new EpicsUDPGWConnection( this, this.connectorCodec, new IPEndPoint(IPAddress.Parse(ipTo), this.Config.BeaconPortTo)); this.BeaconHandler = new Beaconizer(this.UdpConnFrom, this.Config.BeaconPortFrom); ThreadPool.QueueUserWorkItem( delegate { Thread.Sleep(5 * 60 * 1000); this.Inited = true; this.CareBeacons(); }); }