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); }
internal static void ThrowIfInvitationResponseInvalid(PeerInvitationResponse response) { // throw an exception if the response from the native API was PEER_INVITATION_RESPONSE_ERROR if (response.PeerInvitationResponseType < PeerInvitationResponseType.Declined || response.PeerInvitationResponseType > PeerInvitationResponseType.Expired) { throw new PeerToPeerException(SR.GetString(SR.Collab_InviteFailed)); } }
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); }