Receive an answer

The app needs to receive an answer (a session description in SDP format) from the call recipient (the person receiving the call). The app expects this answer to be stored inside a structured data with an ID based on the random ID provided by the caller.

Contents

Get data identifier handle

The app fetches a data identifier handle for the structured data that is expected to contain the answer.

Get data ID handle

POST /data-id/structured-data
store.js
safeDataId.getStructuredDataHandle(ACCESS_TOKEN, address, 500)

The address of the structured data is based on the app ID (example.signaling.v1) and the random ID provided by the caller. The structured data is unversioned (type 500).

store.js
const address = btoa(`${APP_ID}-${item}`)

Get structured data handle

The app tries to fetch a structured data handle using the data identifier handle of the answer.

Get structured data handle

GET /structured-data/handle/:dataIdHandle
store.js
safeStructuredData.getHandle(ACCESS_TOKEN, dataHandleId)

If the structured data doesn't exist, the app waits 2 seconds and tries again. The app keeps making GET requests to the SAFE Network until it finds a structured data with an ID based on the random ID provided by the caller.

PeerView.js
if (initiator) {
  let poller = window.setInterval(() => {
    readData(myNewId).then((data) => {
      window.clearInterval(poller)
      peer.signal(data.payload)
    })
  }, 2000) // we poll once every 2 seconds
}

Drop data identifier handle

The app drops the data identifier handle of the answer.

Drop data ID handle

DELETE /data-id/:handleId
store.js
safeDataId.dropHandle(ACCESS_TOKEN, dataHandleId)

Fetch the structured data

The app fetches the content of the structured data using the structured data handle.

Read structured data

GET /structured-data/:handleId/:version?
store.js
safeStructuredData.readData(ACCESS_TOKEN, handleId)

Drop the structured data handle

The app drops the structured data handle of the answer.

Drop structured data handle

DELETE /structured-data/handle/:handleId
store.js
safeStructuredData.dropHandle(ACCESS_TOKEN, handleId)

The WebRTC connection is then established!

Connection established

results matching ""

    No results matching ""