Completing the Live Contribution

After a Live Contribution is created, it can be modified to provide additional information. Then, once you're done recording, you need to finish the Live Contribution.

Update request

Because it may be hard to know beforehand what you are about to record, you may want to change the Live Contribution's information after it was created. This is a job for LiveContribution.UpdateRequest.

var request = LiveContribution.UpdateRequest(liveContribution: contribution)
request.fields.what = "Actually, yet another cat video"

let operation =
request.operation(with: authenticatedClient, queue: .main, onSuccess: { liveContribution in
    // The request succeeded. You may want to update the reference you kept of LiveContribution with this updated one.
    contribution = liveContribution
}, onError: { error in
    // An error occurred.
})
operation.start()

On success, the request returns a new LiveContribution object with the updated information.

Finish request

When you create a Live Contribution, the Newzulu Live server will allocate resources to receive, record and forward the video stream from your application.

When you're done streaming, you need to execute a LiveContribution.FinishRequest in order to mark the Live Contribution as finished and enable its resources to be reallocated to another stream.

// We're done streaming.
let request = LiveContribution.FinishRequest(liveContribution: contribution)

let operation =
request.operation(with: authenticatedClient, queue: .main, onSuccess: {
    // Contribution finished, good job !
}, onError: { error in
    // An error occurred.
})
operation.start()

If you fail to execute that request, the server will automatically finish the Live Contribution after a pre-determined period of inactivity.