@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 -->> srv: <i>generate provisional</i>\n<i>answer Sdp1 locally</i>\n<i>based on offer</i>
srv -> app: POST or NOTIFY\nVvoipOfferAnswerNotification(pranswer, answerSdp1=Sdp1)
app -->> bro: <i>peerConnection.SetRemoteDescription(pranswer, answerSdp1)</i>

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

srv -->>]: <i>INVITE(userId, offerSdp2=Sdp1)</i>

group answering phase - no 183 response
	note right of srv: Terminating participant is alerted
	srv<<--]: <i>180 Ringing</i>
	srv -> app: POST or NOTIFY VvoipEventNotification(Alerting)

	note right of srv: Terminating participant accepts
	srv<<--]: <i>200 OK INVITE(answerSdp2)</i>
	srv-->>]: <i>ACK</i>
	srv -> app: POST or NOTIFY\nVvoipAcceptanceNotification(answer, answerSdp2)
	app -->> bro: <i>peerConnection.setRemoteDescription(answer, answerSdp2)</i>
end

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>200 OK BYE</i>

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

@enduml