@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 -> srv: generate provisional \nanswer Sdp1 locally\n based on offer
srv -> app: POST or NOTIFY\nVvoipOfferAnswerNotification(pranswer, answerSdp1=Sdp1)
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 

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

group answering phase - no 183 response
	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(answerSdp2)
	srv->]: ACK
	srv -> app: POST or NOTIFY\nVvoipAcceptanceNotification(answer, answerSdp2)
	app -> bro: peerConn.setRemoteDescription(answer, answerSdp2)
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 ->]: BYE
srv <-]: 200 OK BYE

app -> bro: peerConn.Close()

@enduml