Invitations

This section explains how we can subscribe to invitation events

We need an InvitationEventDelegate to receive invitations events

let delegate = InvitationEventDelegateExample()
SippoClient.client.invitations.delegate = delegate
public class SippoConferenceDelegateExample: SippoConferenceDelegate {

    public func conferenceUpdated(_ conference: SippoConference) {

    }

    public func conferenceDestroyed() {

    }

    public func conference(_ conference: SippoConference, didAddParticpant: String) {
        let videoView = conference.viewFor(participant: didAddParticpant, frame: CGRect.zero)
    }

    public func conference(_ conference: SippoConference, didRemoveParticpant: String) {

    }

    public func conference(_ conference: SippoConference, didCancelInvitation: String) {

    }
}

let sippoConferenceDelegate = SippoConferenceDelegateExample()

class InvitationsEventDelegateExample: InvitationsEventDelegate {

    func invitations(_ invitations: Invitations, didCancelInvitationRequest: String) {

    }

    func invitations(_ invitations: Invitations, didReceiveInvitationRequest: InvitationRequest) {
        // Do action with InvitationRequest
        // Like accept it sending a new conference as answer to the InvitationRequest
        invitations.replyWithConference(sippoInvitationRequest: didReceiveInvitationRequest, conferenceDelegate: sippoConferenceDelegate() { task in

        }
        // Or decline
        invitations.decline(sippoInvitationRequest: didReceiveInvitationRequest)
    }
    }
}

To receive new conference events ConferencesDelegate must be implemented and set as Conferences delegate

public class ConferencesDelegateExample: ConferencesDelegate {

// Here we received an invitation to a new conference, we can accept with join or use `Invitations`passed as argument
// to decline it

func conferences(_ conferences: Conferences, didReceiveNewConference: SippoConference, fromUser: String) {
    /*
     In join action we can pass the media that we want to share, or pass nil to use invitation media,
     (this is the media that the caller use for the invite)
    */

    didReceiveNewConference.delegate = sippoConferenceDelegate
    didReceiveNewConference.join(for: [.video]) { task in
        // Check result
    }
    /*
     Decline example
     */
    didReceiveNewConference.declineInvitation { result in

    }


}

} let conferencesDelegate = ConferencesDelegateExample() SippoClient.client.conferences.conferencesDelegate = conferencesDelegate

To receive events related to this conference it’s needed to set a delegate didReceiveConference.delegate = aDelegate