示例#1
0
        /// <summary>
        /// Returns NodeInfo structure of the profile server.
        /// </summary>
        /// <returns>NodeInfo structure of the profile server.</returns>
        public Iop.Locnet.NodeInfo GetNodeInfo()
        {
            log.Trace("()");

            Iop.Locnet.NodeInfo res = null;
            lock (internalLock)
            {
                res = new Iop.Locnet.NodeInfo()
                {
                    NodeId  = ProtocolHelper.ByteArrayToByteString(new byte[0]),
                    Contact = new Iop.Locnet.NodeContact()
                    {
                        IpAddress  = ProtocolHelper.ByteArrayToByteString(ipAddress.GetAddressBytes()),
                        ClientPort = (uint)locPort,
                        NodePort   = (uint)locPort
                    },
                    Location = nodeLocation,
                };

                Iop.Locnet.ServiceInfo serviceInfo = new Iop.Locnet.ServiceInfo()
                {
                    Type        = Iop.Locnet.ServiceType.Profile,
                    Port        = (uint)primaryInterfacePort,
                    ServiceData = ProtocolHelper.ByteArrayToByteString(networkId)
                };
                res.Services.Add(serviceInfo);
            }

            log.Trace("(-)");
            return(res);
        }
示例#2
0
        /// <summary>
        /// Returns location network node information.
        /// </summary>
        /// <param name="LocPort">Port of the associated LOC server.</param>
        /// <returns>NodeInfo structure describing the server in location network.</returns>
        public Iop.Locnet.NodeInfo GetNodeInfo(int LocPort)
        {
            Iop.Locnet.NodeInfo res = new Iop.Locnet.NodeInfo()
            {
                NodeId   = ProtocolHelper.ByteArrayToByteString(new byte[0]),
                Location = new Iop.Locnet.GpsLocation()
                {
                    Latitude  = location.GetLocationTypeLatitude(),
                    Longitude = location.GetLocationTypeLongitude()
                },
                Contact = new Iop.Locnet.NodeContact()
                {
                    IpAddress  = ProtocolHelper.ByteArrayToByteString(ipAddress.GetAddressBytes()),
                    NodePort   = (uint)LocPort,
                    ClientPort = (uint)LocPort
                },
            };

            Iop.Locnet.ServiceInfo serviceInfo = new Iop.Locnet.ServiceInfo()
            {
                Type        = Iop.Locnet.ServiceType.Profile,
                Port        = (uint)primaryPort,
                ServiceData = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(keys.PublicKey))
            };

            res.Services.Add(serviceInfo);
            return(res);
        }