예제 #1
0
        internal WorkerPeer GetPeer(int id)
        {
            WorkerPeer peer = null;

            if (this.worker.Peers.TryGetValue(id, out peer))
            {
                return(peer);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        internal WorkerPeer CreatePeer(CooperatingWorker cow)
        {
            var workerPeer = new WorkerPeer
            {
                Id          = worker.GetNextTaskId(),
                TasksUrl    = cow.TasksUrl,
                CapacityUrl = cow.CapacityUrl
            };


            if (this.worker.Peers.TryAdd(workerPeer.Id, workerPeer))
            {
                return(workerPeer);
            }
            else
            {
                return(null);
            }
        }