LCM.LCM.URLParser.Get C# (CSharp) Method

Get() public method

Get value of a parameter
public Get ( string key, bool def ) : bool
key string parameter name
def bool default value
return bool
        public bool Get(string key, bool def)
		{
            string v = Get(key);

            if (v == null)
            {
                return def;
            }

			return Boolean.Parse(v) || v.Equals("1");
		}

Same methods

URLParser::Get ( string key, double def ) : double
URLParser::Get ( string key, int def ) : int
URLParser::Get ( string key ) : string
URLParser::Get ( string key, string def ) : string

Usage Example

        /* Methods */
        /// <summary>
        /// UDP multicast provider constructor
        /// </summary>
        /// <param name="lcm">LCM object</param>
        /// <param name="up">URL parser object</param>
        public UDPMulticastProvider(LCM lcm, URLParser up)
        {
            this.lcm = lcm;

            string[] addrport = up.Get("network", DEFAULT_NETWORK).Split(':');

            inetAddr = Dns.GetHostAddresses(addrport[0])[0];
            inetPort = Int32.Parse(addrport[1]);
            inetEP   = new IPEndPoint(inetAddr, inetPort);
            Debug.Log(inetEP);

            sock = new UdpClient();
            sock.MulticastLoopback   = true;
            sock.ExclusiveAddressUse = false;
            sock.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
            sock.Client.Bind(new IPEndPoint(IPAddress.Any, inetPort));

            int ttl = up.Get("ttl", DEFAULT_TTL);

            if (ttl == 0)
            {
                Console.Error.WriteLine("LCM: TTL set to zero, traffic will not leave localhost.");
            }
            else if (ttl > 1)
            {
                Console.Error.WriteLine("LCM: TTL set to > 1... That's almost never correct!");
            }
            else
            {
                Console.Error.WriteLine("LCM: TTL set to 1.");
            }
            sock.Ttl = (short)ttl;

            sock.JoinMulticastGroup(inetAddr);
        }
All Usage Examples Of LCM.LCM.URLParser::Get