Example #1
0
        private IWorkerService getChannelToWorker(WorkerInformations worker)
        {
            NetTcpBinding   myBinding  = new NetTcpBinding();
            EndpointAddress myEndpoint = new EndpointAddress(worker.URL);

            ChannelFactory <IWorkerService> myChannelFactory = new ChannelFactory <IWorkerService>(myBinding, myEndpoint);

            IWorkerService workerChannel = myChannelFactory.CreateChannel();

            return(workerChannel);
        }
Example #2
0
        public string Register(string ip)
        {
            int newVal = Interlocked.Increment(ref workerCounter);

            WorkerInformations info = new WorkerInformations();
            string             url  = "net.tcp://" + ip + ":2700" + newVal + "/IWorkerService";

            info.Id   = workerCounter;
            info.Ip   = ip;
            info.Free = true;
            info.URL  = url;

            workers.TryAdd(url, info);

            Console.WriteLine("Worker sa id-om: " + info.Id + "je spreman za rad,poyy");

            return(url);
        }