/// <summary>
        /// Creates a new identity client.
        /// </summary>
        /// <param name="Name">Identity name.</param>
        /// <param name="Type">Identity type.</param>
        /// <param name="Location">Initial GPS location.</param>
        /// <param name="ImageMask">File name mask in the images folder that define which images can be randomly selected for profile image.</param>
        /// <param name="ImageChance">An integer between 0 and 100 that specifies the chance of each instance to have a profile image set.</param>
        public IdentityClient(string Name, string Type, GpsLocation Location, string ImageMask, int ImageChance)
        {
            log = new PrefixLogger("ProfileServerSimulator.IdentityClient", "[" + Name + "] ");
            log.Trace("(Name:'{0}',Type:'{1}',Location:{2},ImageMask:'{3}',ImageChance:{4})", Name, Type, Location, ImageMask, ImageChance);

            name      = Name;
            type      = Type;
            location  = Location;
            extraData = null;

            bool hasImage = Helpers.Rng.NextDouble() < (double)ImageChance / 100;

            if (hasImage)
            {
                imageFileName = GetImageFileByMask(ImageMask);
                profileImage  = imageFileName != null?File.ReadAllBytes(imageFileName) : null;
            }

            version        = SemVer.V100;
            keys           = Ed25519.GenerateKeys();
            identityId     = Crypto.Sha256(keys.PublicKey);
            messageBuilder = new MessageBuilder(0, new List <SemVer>()
            {
                SemVer.V100
            }, keys);

            profileInitialized = false;
            hostingActive      = false;

            log.Trace("(-)");
        }
Exemple #2
0
        /// <summary>
        /// Creates a new instance of a profile server.
        /// </summary>
        /// <param name="Name">Unique profile server instance name.</param>
        /// <param name="Location">GPS location of this profile server instance.</param>
        /// <param name="Port">Base TCP port that defines the range of ports that are going to be used by this profile server instance and its related servers.</param>
        public ProfileServer(string Name, GpsLocation Location, int Port)
        {
            log = new PrefixLogger("ProfileServerSimulator.ProfileServer", "[" + Name + "] ");
            log.Trace("(Name:'{0}',Location:{1},Port:{2})", Name, Location, Port);

            this.name     = Name;
            this.location = Location;
            basePort      = Port;
            ipAddress     = IPAddress.Parse("127.0.0.1");

            locPort = basePort;
            primaryInterfacePort           = basePort + 1;
            serverNeighborInterfacePort    = basePort + 2;
            clientNonCustomerInterfacePort = basePort + 3;
            clientCustomerInterfacePort    = basePort + 4;
            clientAppServiceInterfacePort  = basePort + 5;

            availableIdentitySlots = MaxHostedIdentities;
            hostedIdentities       = new List <IdentityClient>();

            nodeLocation = new Iop.Locnet.GpsLocation()
            {
                Latitude  = Location.GetLocationTypeLatitude(),
                Longitude = Location.GetLocationTypeLongitude()
            };

            initializationNeighborhoodNotificationList = new HashSet <ProfileServer>();

            log.Trace("(-)");
        }
Exemple #3
0
        /// <summary>
        /// Initializes the LOC server instance.
        /// </summary>
        /// <param name="ProfileServer">Associated profile server.</param>
        public LocServer(ProfileServer ProfileServer)
        {
            log = new PrefixLogger("ProfileServerSimulator.LocServer", "[" + ProfileServer.Name + "] ");
            log.Trace("()");

            this.profileServer = ProfileServer;
            ipAddress          = ProfileServer.IpAddress;
            port = ProfileServer.LocPort;

            nodeLocation = ProfileServer.NodeLocation;

            listener = new TcpListener(ipAddress, port);
            listener.Server.LingerState = new LingerOption(true, 0);
            listener.Server.NoDelay     = true;

            log.Trace("(-)");
        }