Exemple #1
0
        public void RejectFriendRequest(FriendRequest fr)
        {
            FriendRequestList pl = (FriendRequestList)ServerManager.Instance.ServerInstance.ReadDomainObject("SentFriendRequests");

            if (pl != null)
            {
                pl.RemoveFriendRequest(fr);
                ServerManager.Instance.ServerInstance.WriteDomainObject(pl);
            }
        }
Exemple #2
0
        public void RejectFriendRequest(FriendRequest f)
        {
            try
            {
                ServerManager.Instance.ServerInstance.ServerRequestInvoker.RejectFriendRequest(f);

                f.FriendRequestState = FriendRequest.RequestState.REJECTED;
                FriendRequestList receivedReqs = GetReceivedFriendRequests();
                receivedReqs.RemoveFriendRequest(f);
                ServerManager.Instance.ServerInstance.WriteDomainObject(receivedReqs);
            }
            catch (ServiceUnavailableException)
            {
                throw new ServiceUnavailableException("Não foi possível enviar o pedido.");
            }
            catch (RemotingException)
            {
                throw new ServiceUnavailableException("Não foi possível enviar o pedido.");
            }
        }
Exemple #3
0
        public void AcceptFriendRequest(FriendRequest f)
        {
            try
            {
                ServerManager.Instance.ServerInstance.ServerRequestInvoker.AcceptFriendRequest(f);
                //Get processed requests

                Post     p  = new Post("PADIBook de " + f.RequestedUserName, f.RequestingUserName + " ficou seu amigo. O seu endereço é " + f.FromAddress + ":" + f.FromPort);
                PostList pl = (PostList)ServerManager.Instance.ServerInstance.ReadDomainObject("PostList");
                if (pl == null)
                {
                    pl = new PostList("PostList");
                }
                pl.AddPost(p);
                ServerManager.Instance.ServerInstance.WriteDomainObject(pl);
            }
            catch (ServiceUnavailableException)
            {
                throw new ServiceUnavailableException("Não foi possível enviar a resposta.");
            }
            catch (RemotingException)
            {
                throw new ServiceUnavailableException("Não foi possível enviar o pedido.");
            }
            f.FriendRequestState = FriendRequest.RequestState.ACCEPTED;
            FriendRequestList recvFrdReqs = GetReceivedFriendRequests();

            //add friend
            Friends friends = GetFriendList();

            friends.AddFriend(f.RequestingUserName, f.FromAddress, f.FromPort);
            ServerManager.Instance.ServerInstance.WriteDomainObject(friends);

            //Remove request from received requests
            recvFrdReqs.RemoveFriendRequest(f);
            ServerManager.Instance.ServerInstance.WriteDomainObject(recvFrdReqs);
        }
Exemple #4
0
        public void AcceptFriendRequest(FriendRequest fr)
        {
            //Remove request
            FriendRequestList pl = (FriendRequestList)ServerManager.Instance.ServerInstance.ReadDomainObject("SentFriendRequests");

            if (pl != null)
            {
                pl.RemoveFriendRequest(fr);
                ServerManager.Instance.ServerInstance.WriteDomainObject(pl);
            }

            //Add friend
            Friends plist = (Friends)ServerManager.Instance.ServerInstance.ReadDomainObject("Friends");

            if (plist == null)
            {
                plist = new Friends("Friends");
            }
            //  Add only if we're not already friends
            if (!plist.FriendsInfo.ContainsKey(fr.RequestedUserName))
            {
                plist.AddFriend(fr.RequestedUserName, fr.SendTo, fr.SendToPort);
                ServerManager.Instance.ServerInstance.WriteDomainObject(plist);

                //Add post
                Post     p     = new Post("PADIBook de " + fr.RequestingUserName, fr.RequestedUserName + " ficou seu amigo.O seu endereço é " + fr.SendTo + ":" + fr.SendToPort);
                PostList postl = (PostList)ServerManager.Instance.ServerInstance.ReadDomainObject("PostList");
                if (postl == null)
                {
                    postl = new PostList("PostList");
                    ServerManager.Instance.ServerInstance.WriteDomainObject(postl);
                }
                postl.AddPost(p);
                ServerManager.Instance.ServerInstance.WriteDomainObject(postl);
            }
        }