Exemplo n.º 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));
        }
Exemplo n.º 2
0
 public Friend sendFriendRequest(Friend friend)
 {
     ClientApp._user.addPendingFriend(friend);
     UpdateTextBoxesDelegate updateDelegate = new UpdateTextBoxesDelegate(ClientApp._form.refreshMyPendingFriends);
     ClientApp._form.BeginInvoke(updateDelegate);
     return null;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 6
0
Arquivo: User.cs Projeto: 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);
        }
Exemplo n.º 7
0
Arquivo: User.cs Projeto: archie/sesun
 public void addFriend(Friend friend)
 {
     _friends.Add(friend);
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
        }