예제 #1
0
        public Friend acceptFriendRequest(Friend friend)
        {
            try
            {
                friend.SucessorSwarm = true;
                ServerApp._user.addFriend(friend);
                //ServerApp._user.PendingFriends.Remove(friend);
            }
            catch (DuplicatePendingFriendException ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return null;
            }

            ClientServices client = (ClientServices)Activator.GetObject(typeof(ClientServices),
               ServerApp._clientUri + "/" + ServicesNames.ClientServicesName);

            RemoteAsyncFriendDelegate del = new RemoteAsyncFriendDelegate(client.acceptFriendRequest);

            del.BeginInvoke(friend, null, null);

            string[] myUris = { ServerApp._primaryURI };//, ServerApp._replicaOneURI, ServerApp._replicaTwoURI };

            return new Friend(ServerApp._user.Username, new List<string>(myUris));
        }
예제 #2
0
 public Friend sendFriendRequest(Friend friend)
 {
     ClientApp._user.addPendingFriend(friend);
     UpdateTextBoxesDelegate updateDelegate = new UpdateTextBoxesDelegate(ClientApp._form.refreshMyPendingFriends);
     ClientApp._form.BeginInvoke(updateDelegate);
     return null;
 }
예제 #3
0
        public Friend acceptFriendRequest(Friend friend)
        {
            ClientServices client;

            if (!ServerApp._serviceAvailable)
            {
                client = ((ClientServices)Activator.GetObject(typeof(ClientServices),
                    ServerApp._clientUri + "/" + ServicesNames.ClientServicesName));
                new RemoteAsyncServiceUnavailableDelegate(client.serviceUnavailable).BeginInvoke(null, null);
                return null;
            }

            string friendUri = friend.Uris.ElementAt(0);

            string[] myUris = { ServerApp._primaryURI};//, ServerApp._replicaOneURI, ServerApp._replicaTwoURI };

            Friend user = new Friend(ServerApp._user.Username, new List<string>(myUris));

            ServerToServerServices server = (ServerToServerServices)Activator.GetObject(
                                typeof(ServerToServerServices),
                                friendUri + "/" + ServicesNames.ServerToServerServicesName);

            AsyncCallback remoteCallback = new AsyncCallback(remoteAsyncAcceptFriendRequestCallback);
            RemoteAsyncFriendDelegate del = new RemoteAsyncFriendDelegate(server.acceptFriendRequest);
            del.BeginInvoke(user, remoteCallback, null);

            return null;
        }
예제 #4
0
        public Friend acceptFriendRequest(Friend friend)
        {
            RemoteAsyncPostDelegate postDel;
            AsyncCallback postCallback;

            ClientApp._user.addFriend(friend);
            try
            {
                if (ClientApp._user.getPendingFriend(friend.Name) != null)
                    ClientApp._user.removePendingFriend(friend.Name);
            }
            catch (Exception) { }
            UpdateTextBoxesDelegate updateDelegate = new UpdateTextBoxesDelegate(ClientApp._form.refreshMyFriends);
            updateDelegate += ClientApp._form.refreshMyPendingFriends;
            ClientApp._form.BeginInvoke(updateDelegate);

            postCallback = new AsyncCallback(ClientApp._form.remoteAsyncSendPostCallBack);
            postDel = new RemoteAsyncPostDelegate(ClientApp._form.Server.sendPost);

            postDel.BeginInvoke(new Post(postMessage(ClientApp._user.Username,friend.Name),ClientApp._user.Username),postCallback,null);

            return null;
        }
예제 #5
0
        public Friend sendFriendRequest(Friend friend)
        {
            MessageBox.Show(ServerApp._user.Username + " -> ServerToserver : sendFriendRequest(adds pending friend) : " + friend.Name + " %s" +friend.Uris.ElementAt(0));

            try
            {
                ServerApp._user.addPendingFriend(friend);
            }
            catch (DuplicatePendingFriendException ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return null;
            }

            ClientServices client = (ClientServices)Activator.GetObject(typeof(ClientServices),
                ServerApp._clientUri + "/" + ServicesNames.ClientServicesName);

            RemoteAsyncFriendDelegate del = new RemoteAsyncFriendDelegate(client.sendFriendRequest);
            del.BeginInvoke(friend, null, null);

            return null;
        }
예제 #6
0
파일: User.cs 프로젝트: archie/sesun
        public void addPendingFriend(Friend friend)
        {
            string newPendingFriendName = friend.Name;

            foreach (Friend pendingFriend in _pendingFriends)
                if (pendingFriend.Name.Equals(newPendingFriendName))
                    throw new DuplicatePendingFriendException("Duplicate pending friend");

            _pendingFriends.Add(friend);
        }
예제 #7
0
파일: User.cs 프로젝트: archie/sesun
 public void addFriend(Friend friend)
 {
     _friends.Add(friend);
 }
예제 #8
0
        //TODO: depois tem que ter callback
        public void sendFriendRequest(string friendUri)
        {
            ClientServices client;

            if (!ServerApp._serviceAvailable)
            {
                client = ((ClientServices)Activator.GetObject(typeof(ClientServices),
                    ServerApp._clientUri + "/" + ServicesNames.ClientServicesName));
                new RemoteAsyncServiceUnavailableDelegate(client.serviceUnavailable).BeginInvoke(null, null);
                return;
            }

            try
            {
                List<String> replicasUri = new List<string>();
                replicasUri.Add(ServerApp._myUri);
                //string[] replicasURIs = new string[] { ServerApp._primaryURI };
                //                      //ServerApp._replicaOneURI,ServerApp._replicaTwoURI };

                MessageBox.Show(ServerApp._user.Username + " -> ClientToServer : sendFriendRequest : " + ServerApp._user.Username + " - " + replicasUri.ElementAt(0));
                Friend friend = new Friend(ServerApp._user.Username,replicasUri,true);

                ServerToServerServices server = (ServerToServerServices)Activator.GetObject(
                    typeof(ServerToServerServices),
                    friendUri + "/" + ServicesNames.ServerToServerServicesName);

                RemoteAsyncFriendDelegate del =
                    new RemoteAsyncFriendDelegate(server.sendFriendRequest);

                System.Windows.Forms.MessageBox.Show("vou adicionar pending friend " + friendUri);
                del.BeginInvoke(friend, null, null);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
        }
예제 #9
0
        public Friend removeFriendRequest(Friend friend)
        {
            if (!ServerApp._serviceAvailable)
                return null;

            try
            {
                ServerApp._user.removePendingFriend(friend.Name);
            }
            catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "aqui"); }

            return friend;
        }