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.
POST /data-id/structured-data
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).
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/:dataIdHandle
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.
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.
DELETE /data-id/:handleId
safeDataId.dropHandle(ACCESS_TOKEN, dataHandleId)
Fetch the structured data
The app fetches the content of the structured data using the structured data handle.
GET /structured-data/:handleId/:version?
safeStructuredData.readData(ACCESS_TOKEN, handleId)
Drop the structured data handle
The app drops the structured data handle of the answer.
DELETE /structured-data/handle/:handleId
safeStructuredData.dropHandle(ACCESS_TOKEN, handleId)
The WebRTC connection is then established!

Last updated
Was this helpful?