@startuml
!include skin.inc

autonumber "#'.'"

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

note left of srv: Receive session invitation \nwith offerSdp1
srv -> app: POST or NOTIFY WrtcsSessionInvitationNotification(offerSdp1, sessionId)

app -->> bro: <i>Create PeerConnection and set up media sources</i>
app -->> bro: <i>peerConnection.SetRemoteDescription(offer, offerSdp1)</i>
app -->> bro: <i>answerSdp1=peerConnection.CreateAnswer()</i>
app -->> bro: <i>peerConnection.SetLocalDescription(answer, answerSdp1)</i>

app -> srv: PUT WrtcsAnswer(answer, answerSdp1)
srv --> app: Response
note left of srv: Send answer 

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

note left of srv: Send ringing indication
app -->> app: <i>Alert the user</i>
note right of app: User accepts
app -> srv: PUT WrtcsSessionStatus(Connected)
srv --> app: Response

note left of srv: Send acceptance indication
note over bro, srv
 Originator and Terminating Participant are in a call now.
end note

note left of srv: Receive termination request
srv -> app: POST or NOTIFY WrtcsEventNotification(SessionEnded)
app -->> bro: <i>peerConnection.Close()</i>

@enduml