Esempio n. 1
0
        public override PeerInvitationResponse Invite()
        {
            if (m_Disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            PeerCollaborationPermission.UnrestrictedPeerCollaborationPermission.Demand();

            Guid appGuid = CurrentApplicationGuid;

            if (appGuid.Equals(Guid.Empty))
            {
                throw new PeerToPeerException(SR.GetString(SR.Collab_NoGuidForCurrApp));
            }

            //
            // We need at least one endpoint to send invitation to
            //
            PeerEndPointCollection peerEndPoints = PeerEndPoints;

            if ((peerEndPoints == null) || (peerEndPoints.Count == 0))
            {
                throw new PeerToPeerException(SR.GetString(SR.Collab_NoEndpointFound));
            }

            PeerEndPoint peerEndPoint = PeerEndPoints[0];

            PeerInvitationResponse response = InternalInviteEndPoint(appGuid, null, null, peerEndPoint, null);

            // throw an exception if the response type is ERROR
            CollaborationHelperFunctions.ThrowIfInvitationResponseInvalid(response);
            return(response);
        }
Esempio n. 2
0
        public override PeerInvitationResponse Invite(PeerApplication applicationToInvite, string message,
                                                      byte[] invitationData)
        {
            if (m_Disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            PeerCollaborationPermission.UnrestrictedPeerCollaborationPermission.Demand();

            if (applicationToInvite == null)
            {
                throw new ArgumentNullException("applicationToInvite");
            }
            if (applicationToInvite.Id == Guid.Empty)
            {
                throw new PeerToPeerException(SR.GetString(SR.Collab_EmptyGuidError));
            }

            //
            // We need at least one endpoint to send invitation to
            //
            PeerEndPointCollection peerEndPoints = PeerEndPoints;

            if ((peerEndPoints == null) || (peerEndPoints.Count == 0))
            {
                throw new PeerToPeerException(SR.GetString(SR.Collab_NoEndpointFound));
            }

            PeerEndPoint peerEndPoint = PeerEndPoints[0];

            PeerInvitationResponse response = InternalInviteEndPoint(applicationToInvite.Id, message, invitationData,
                                                                     peerEndPoint, null);

            // throw an exception if the response type is ERROR
            CollaborationHelperFunctions.ThrowIfInvitationResponseInvalid(response);
            return(response);
        }