@startuml
!include skin.inc

participant "<i>Browser</i>" as bro #ffffff
participant "Application" as app 
participant "Server" as srv 


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

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

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

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

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

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

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

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

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 -->>]: <i>BYE</i>
srv <<--]: <i>ACK</i>

app -->> bro: <i>peerConnection.Close()</i>

@enduml