public void getName(String responseUri) { ServerToServerServices friend = ((ServerToServerServices)Activator.GetObject(typeof(ServerToServerServices), responseUri + "/" + ServicesNames.ServerToServerServicesName)); RemoteAsyncChangeNameInFriendsDelegate remoteDel = new RemoteAsyncChangeNameInFriendsDelegate(friend.changeNameOfFriend); remoteDel.BeginInvoke(ServerApp._user.Username, ServerApp._primaryURI, null, null); }
public void changeNameOfFriend(String name, String primary) { foreach (Friend f in ServerApp._user.Friends) { if (f.Uris.ElementAt(0).CompareTo(primary) == 0) { f.Name = name; } } ClientServices client = (ClientServices)Activator.GetObject(typeof(ClientServices), ServerApp._clientUri + "/" + ServicesNames.ClientServicesName); RemoteAsyncChangeNameInFriendsDelegate changedel = new RemoteAsyncChangeNameInFriendsDelegate(client.changeNameOfFriend); RemoteAsyncRefreshFriendsDelegate del = new RemoteAsyncRefreshFriendsDelegate(client.refreshFriends); del.BeginInvoke(null, null); changedel.BeginInvoke(name, primary, null, null); }
public void modifyUserProfile(String name, String spoofaddr) { ClientServices client; ServerApp._user.SpoofAdress = spoofaddr; if (!ServerApp._serviceAvailable) { client = ((ClientServices)Activator.GetObject(typeof(ClientServices), ServerApp._clientUri + "/" + ServicesNames.ClientServicesName)); new RemoteAsyncServiceUnavailableDelegate(client.serviceUnavailable).BeginInvoke(null,null); return; } //string[] replicasURIs = { ServerApp._replicaOneURI, ServerApp._replicaTwoURI }; //ReplicationServices replica; //RemoteAsyncModifyUserProfileDelegate remoteDel; ServerToServerServices friend; //RemoteAsyncLookupInterestDelegate generalDel; //QueryByInterest q = new QueryByInterest(Interest.Cars, new List<String>(), new List<String>()); //int interestsfound = 0; /*foreach (string uri in replicasURIs) { if (uri != null) { //System.Windows.Forms.MessageBox.Show("vai replicar no " + uri); replica = ((ReplicationServices)Activator.GetObject(typeof(ReplicationServices), uri + "/" + ServicesNames.ReplicationServicesName)); remoteDel = new RemoteAsyncModifyUserProfileDelegate(replica.modifyUserProfile); remoteDel.BeginInvoke(time, name, gen, inter, null, null); } }*/ if (ServerApp._user.Username.CompareTo(name) != 0) { foreach (Friend i in ServerApp._user.Friends) { if (i.Uris.ElementAt(0) != null) { //System.Windows.Forms.MessageBox.Show("Mudou de nome->manda changeNameOnF para " + i.Uris.ElementAt(0)); friend = ((ServerToServerServices)Activator.GetObject(typeof(ServerToServerServices), i.Uris.ElementAt(0) + "/" + ServicesNames.ServerToServerServicesName)); RemoteAsyncChangeNameInFriendsDelegate superDelegate = new RemoteAsyncChangeNameInFriendsDelegate(friend.changeNameOfFriend); superDelegate.BeginInvoke(name, ServerApp._primaryURI, null, null); } } ServerApp._user.Username = name; } //ServerApp._user.Gender = gen; //ServerApp._user.BirthDate = time; //if (ServerApp._user.IsRegisteredInAnelGeral) // MessageBox.Show(ServerApp._user.Username + " : Ja estou no anel geral"); /* foreach (Interest i in inter) { foreach (RegisteredInterest r in ServerApp._user.RegInterests) { //TODO acabar o registo de interesses if (i.Equals(r.Interest)) { interestsfound++; break; } } } if (inter.Count != interestsfound) { System.Windows.Forms.MessageBox.Show("tenho de registar interesses."); /*Vai fazer lookup do interesse por uma via ligeiramente diferente*/ /*Os lookups devolvem sempre o ultimo uri por onde passou*/ //q.Interest = i; /*q.refreshTimeStamp(); q.Uris.Add(ServerApp._primaryURI); q.Uris.Add(ServerApp._replicaOneURI); q.Uris.Add(ServerApp._replicaTwoURI); q.ContactingServerUri.Add(ServerApp._primaryURI); q.ContactingServerUri.Add(ServerApp._replicaOneURI); q.ContactingServerUri.Add(ServerApp._replicaTwoURI); foreach (Friend f in ServerApp._user.Friends) { if (f.Uris.ElementAt(0) != null) { System.Windows.Forms.MessageBox.Show(ServerApp._user.Username + " : Server do cliente recebeu e manda lookupGRing para " + f.Uris.ElementAt(0)); friend = ((ServerToServerServices)Activator.GetObject(typeof(ServerToServerServices), f.Uris.ElementAt(0) + "/" + ServicesNames.ServerToServerServicesName)); generalDel = new RemoteAsyncLookupInterestDelegate(friend.lookupGeneralRing); generalDel.BeginInvoke(q, null, null); } } } */ //ServerApp._user.Interests = inter; }