@startuml
!include skin.inc

autonumber "#'.'"

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

[-->>srv: <i>INVITE(userId)</i>
srv -> app: POST or NOTIFY WrtcsSessionInvitationNotification(sessionId)

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: PUT WrtcsOffer(offer, offerSdp1)
srv --> app: Response
[<<--srv: <i>183 Session Progress(offerSdp; 100rel)</i> 
[-->>srv: <i>PRACK(answerSDP)</i> 
[<<--srv: <i>200 OK PRACK</i> 

srv -> app: POST or NOTIFY\nWrtcsAnswerNotification(answer, answerSdp1)
app -->> bro: <i>peerConnection.SetRemoteDescription(answer, answerSdp1)</i>

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

app -> srv: PUT WrtcsSessionStatus(Ringing)
srv --> app: Response

[<<--srv: <i>180 Ringing</i> 
app -->> app: <i>Alert the user</i>
note right of app: User accepts
app -> srv: PUT WrtcsSessionStatus(Connected)
srv --> app: Response

[<<--srv: <i>200 OK INVITE</i> 
note over bro, srv
 Originator and Terminating Participant are in a call now.
end note

@enduml