feat: implement call ack

This commit is contained in:
Adhiraj Singh
2021-11-11 11:24:10 +05:30
parent 05b3095bfd
commit d8c8d46adb
2 changed files with 16 additions and 0 deletions

View File

@@ -428,6 +428,15 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
logger.debug({ attrs: node.attrs }, 'sending receipt for ack')
})
ws.on('CB:call', async(node: BinaryNode) => {
logger.info({ node }, 'recv call')
const [child] = getAllBinaryNodeChildren(node)
if(child.tag === 'terminate' || child.tag === 'relaylatency') {
await sendMessageAck(node, { class: 'call', type: child.tag })
}
})
const handleReceipt = async(node: BinaryNode) => {
const { attrs, content } = node
const isRead = isReadReceipt(attrs.type)

View File

@@ -276,6 +276,13 @@ export const getBinaryNodeChildren = ({ content }: BinaryNode, childTag: string)
return []
}
export const getAllBinaryNodeChildren = ({ content }: BinaryNode) => {
if(Array.isArray(content)) {
return content
}
return []
}
export const getBinaryNodeChild = ({ content }: BinaryNode, childTag: string) => {
if(Array.isArray(content)) {
return content.find(item => item.tag == childTag)