예제 #1
0
        public void DestroySpawner(RegisteredSpawner spawner)
        {
            var peer = spawner.Peer;

            if (peer != null)
            {
                var peerRooms =
                    peer.GetProperty((int)MsfPropCodes.RegisteredSpawners) as Dictionary <int, RegisteredSpawner>;

                // Remove the spawner from peer
                if (peerRooms != null)
                {
                    peerRooms.Remove(spawner.SpawnerId);
                }
            }

            // Remove the spawner from all spawners
            Spawners.Remove(spawner.SpawnerId);

            // Invoke the event
            if (SpawnerDestroyed != null)
            {
                SpawnerDestroyed.Invoke(spawner);
            }
        }
예제 #2
0
        public virtual RegisteredSpawner CreateSpawner(IPeer peer, SpawnerOptions options)
        {
            var spawner = new RegisteredSpawner(GenerateSpawnerId(), peer, options);

            var peerSpawners =
                peer.GetProperty((int)MsfPropCodes.RegisteredSpawners) as Dictionary <string, RegisteredSpawner>;

            if (peerSpawners == null)
            {
                // If this is the first time registering a spawners

                // Save the dictionary
                peerSpawners = new Dictionary <string, RegisteredSpawner>();
                peer.SetProperty((int)MsfPropCodes.RegisteredSpawners, peerSpawners);

                peer.Disconnected += OnRegisteredPeerDisconnect;
            }

            // Add a new spawner
            peerSpawners[spawner.SpawnerId] = spawner;

            // Add the spawner to a list of all spawners
            Spawners[spawner.SpawnerId] = spawner;

            // Invoke the event
            if (SpawnerRegistered != null)
            {
                SpawnerRegistered.Invoke(spawner);
            }

            return(spawner);
        }
예제 #3
0
        public SpawnTask(int spawnTaskId, RegisteredSpawner spawner, DictionaryOptions properties, DictionaryOptions customOptions)
        {
            Id = spawnTaskId;

            Spawner       = spawner;
            Options       = properties;
            CustomOptions = customOptions;

            UniqueCode        = Msf.Helper.CreateRandomString(6);
            whenDoneCallbacks = new List <Action <SpawnTask> >();
        }
예제 #4
0
        public SpawnTask(string spawnId, RegisteredSpawner spawner, Dictionary <string, string> properties, string customArgs)
        {
            this.SpawnId = spawnId;

            Spawner    = spawner;
            CustomArgs = customArgs;
            Properties = properties;

            UniqueCode        = Msf.Helper.CreateRandomString(6);
            WhenDoneCallbacks = new List <Action <SpawnTask> >();
        }
예제 #5
0
        /// <summary>
        ///     Requests a specific spawner to spawn a process
        /// </summary>
        /// <param name="properties"></param>
        /// <param name="customArgs"></param>
        /// <param name="spawner"></param>
        /// <returns></returns>
        public virtual SpawnTask Spawn(Dictionary <string, string> properties, string customArgs,
                                       RegisteredSpawner spawner)
        {
            var task = new SpawnTask(GenerateSpawnTaskId(), spawner, properties, customArgs);

            SpawnTasks[task.SpawnId] = task;

            spawner.AddTaskToQueue(task);

            Logger.Debug("Spawner was found, and spawn task created: " + task);

            return(task);
        }
예제 #6
0
        /// <summary>
        /// Requests a specific spawner to spawn a process
        /// </summary>
        /// <param name="properties"></param>
        /// <param name="customArgs"></param>
        /// <param name="spawner"></param>
        /// <returns></returns>
        public virtual SpawnTask Spawn(Dictionary <string, string> properties, string customArgs, RegisteredSpawner spawner, string spawnID)
        {
            var task = new SpawnTask(spawnID, spawner, properties, customArgs);

            if (SpawnTasks.ContainsKey(task.UniqueCode))
            {
                Debug.LogError("Already have Spawner: " + task.UniqueCode);
                SpawnTasks.Remove(task.UniqueCode);
            }

            SpawnTasks.Add(task.UniqueCode, task);
            spawner.AddTaskToQueue(task);

            return(task);
        }
        /// <summary>
        /// Start process on spawner side with given spawn <paramref name="options"/>, <paramref name="customOptions"/> and <paramref name="spawner"/>
        /// </summary>
        /// <param name="options"></param>
        /// <param name="customOptions"></param>
        /// <param name="spawner"></param>
        /// <returns></returns>
        public virtual SpawnTask Spawn(DictionaryOptions options, DictionaryOptions customOptions, RegisteredSpawner spawner)
        {
            // Create new spawn task
            var task = new SpawnTask(GenerateSpawnTaskId(), spawner, options, customOptions);

            // List this task
            spawnTasksList[task.Id] = task;

            // Add this task to queue
            spawner.AddTaskToQueue(task);

            logger.Debug("Spawner was found, and spawn task created: " + task);

            return(task);
        }