コード例 #1
0
ファイル: SwarmMemory.cs プロジェクト: shranjan/pinac
        //this function is used to give a privilege to a computer for the first time, so it includes
        //the source code as well among the parameters. before that it has to initialize all the other
        //data on the new machine so it calls createInitialData function
        public void addPermissionRequest(string myIPPort, Hashtable dests, string code, string IPPort, string read, string write)
        {

            createInitialData(IPPort);
            string[] privileges = { read, write };
            permissions[IPPort]= privileges;

            List<string> endPoints = Peers();
            Hashtable temp = dests;
            List<string> removed = new List<string>();
            foreach (DictionaryEntry item in temp)
            {
                if (!endPoints.Contains(item.Key.ToString()))
                {
                    removed.Add(item.Key.ToString());
                }
            }
            for (int i = 0; i < removed.Count; i++)
			{
			    temp.Remove(removed[i].ToString());
			}
            
            code = "<newProg>" +"<code>"+ code +"</code>"+"<Pid>"+Pid+"</Pid>"+"<IPPort>"+IPPort+"</IPPort>"+"<read>"+read+"</read>"+"<write>"+write+"</write>"+"</newProg>";
           // Console.WriteLine(code); //this line is a part of test1
            AsynchronousClient client = new AsynchronousClient();
            client.SetMultiMsg(temp, code, myIPPort);
            Thread t = new Thread(new ThreadStart(client.SendMultiClient));
            t.Start();
            t.IsBackground = true;
            
        }
コード例 #2
0
ファイル: SwarmMemory.cs プロジェクト: shranjan/pinac
 public void changePermissionRequest(string myIPPort, Hashtable dests, string IPPort, string read, string write)
 {
    
     string[] privileges = { read, write };
     permissions[IPPort] = privileges;
     List<string> endPoints = Peers();
     Hashtable temp = dests;
     List<string> removed = new List<string>();
     foreach (DictionaryEntry item in temp)
     {
         if (!endPoints.Contains(item.Key.ToString()))
             removed.Add(item.Key.ToString());
     }
     for (int i = 0; i < removed.Count; i++)
     {
         temp.Remove(removed[i].ToString());
     }
     string permissionMessage = changePermissionMessage(IPPort, read, write);
     AsynchronousClient client = new AsynchronousClient();
     client.SetMultiMsg(temp, permissionMessage, myIPPort);
     Thread t = new Thread(new ThreadStart(client.SendMultiClient));
     t.Start();
     t.IsBackground = true;
     
 }