@startuml
!include skin.inc

participant "Browser" as bro 
participant "Application" as app 
participant "Server" as srv 


note left of bro 
	Visit site and 
	download Application
end note
app -> bro: Create PeerConnection and set up media sources
app -> bro: offerSdp1=peerConn.CreateOffer()
app -> bro: peerConn.SetLocalDescription(offer, offerSdp1)

app -> srv: POST VvoipSession(userId, offerSdp1)
srv --> app: Response with sessionId

srv ->]: INVITE(userId, offerSdp1 with PreCo)

srv <-]: 183 Session Progress (answerSdp1; 100rel)
srv ->]: PRACK
srv <-]: 200 OK PRACK
srv -> app: POST or NOTIFY\nVvoipOfferAnswerNotification(pranswer, answerSdp1)
app -> bro: peerConn.setRemoteDescription(pranswer, answerSdp1)

note over bro, srv
 Running ICE connectivity checks
end note
bro -> app: oniceconnectionstatechange(completed)
app -> srv: POST IceStatus(Connected)
srv --> app: Response 

note right of srv: Send offer declaring preconditions as met
srv ->]: UPDATE(offerSdp2)
srv <-]: 200 OK(answerSdp2)
srv -> app: POST or NOTIFY\nVvoipOfferAnswerNotification(answer, answerSdp2)
app -> bro: peerConn.setRemoteDescription(answer, answerSdp2)

note right of srv: Terminating participant is alerted
srv<-]: 180 Ringing
srv -> app: POST or NOTIFY VvoipEventNotification(Alerting)

note right of srv: Terminating participant accepts
srv<-]: 200 OK INVITE
srv->]: ACK

srv -> app: POST or NOTIFY\nVvoipAcceptanceNotification()

note over bro, srv
 Originator and Terminating Participant are in a call now.
end note

app -> srv: DELETE VvoipSession with sessionId
srv --> app: Response
srv ->]: BYE
srv <-]: ACK

app -> bro: peerConn.Close()

@enduml