dring: add call API
Change-Id: I47ed1d6616254b5b6a78a18c452bf548698faed2
diff --git a/JamiDaemon.js b/JamiDaemon.js
index 08dd3cc..efc39c1 100755
--- a/JamiDaemon.js
+++ b/JamiDaemon.js
@@ -31,7 +31,7 @@
this.tempAccounts = []
this.dring = require("./dring.node")
this.dring.init({
- "AccountsChanged": () => {
+ AccountsChanged: () => {
console.log("AccountsChanged")
const newAccounts = []
JamiDaemon.vectToJs(this.dring.getAccountList()).forEach(accountId => {
@@ -48,7 +48,7 @@
})
this.accounts = newAccounts
},
- "AccountDetailsChanged": (accountId, details) => {
+ AccountDetailsChanged: (accountId, details) => {
console.log(`AccountDetailsChanged ${accountId}`)
const account = this.getAccount(accountId)
if (!account) {
@@ -57,7 +57,7 @@
}
account.details = details
},
- "VolatileDetailsChanged": (accountId, details) => {
+ VolatileDetailsChanged: (accountId, details) => {
console.log(`VolatileDetailsChanged ${accountId}`)
const account = this.getAccount(accountId)
if (!account) {
@@ -66,7 +66,7 @@
}
account.volatileDetails = details
},
- "IncomingAccountMessage": (accountId, from, message) => {
+ IncomingAccountMessage: (accountId, from, message) => {
console.log(`Received message: ${accountId} ${from} ${message["text/plain"]}`)
/*
if (parser.validate(message["text/plain"]) === true) {
@@ -79,7 +79,7 @@
//io.emit('receivedMessage', message["text/plain"])
}*/
},
- "RegistrationStateChanged": (accountId, state, code, detail) => {
+ RegistrationStateChanged: (accountId, state, code, detail) => {
console.log("RegistrationStateChanged: " + accountId + " " + state + " " + code + " " + detail)
const account = this.getAccount(accountId)
if (account) {
@@ -100,7 +100,7 @@
}
}
},
- "RegisteredNameFound": (accountId, state, address, name) => {
+ RegisteredNameFound: (accountId, state, address, name) => {
console.log(`RegisteredNameFound: ${accountId} ${state} ${address} ${name}`)
let lookups
if (accountId) {
@@ -128,7 +128,7 @@
index -= 1
}
},
- "NameRegistrationEnded": (accountId, state, name) => {
+ NameRegistrationEnded: (accountId, state, name) => {
console.log(`NameRegistrationEnded: ${accountId} ${state} ${name}`)
const account = this.getAccount(accountId)
if (account) {
@@ -142,7 +142,8 @@
console.log(`Unknown account ${accountId}`)
}
},
- "ConversationReady": (accountId, conversationId) => {
+ // Conversations
+ ConversationReady: (accountId, conversationId) => {
console.log(`conversationReady: ${accountId} ${conversationId}`)
const account = this.getAccount(accountId)
if (!account) {
@@ -157,7 +158,7 @@
account.addConversation(conversation)
}
},
- "ConversationRemoved": (accountId, conversationId) => {
+ ConversationRemoved: (accountId, conversationId) => {
console.log(`conversationRemoved: ${accountId} ${conversationId}`)
const account = this.getAccount(accountId)
if (!account) {
@@ -166,7 +167,7 @@
}
account.removeConversation(conversationId)
},
- "ConversationLoaded": (id, accountId, conversationId, messages) => {
+ ConversationLoaded: (id, accountId, conversationId, messages) => {
console.log(`conversationLoaded: ${accountId} ${conversationId}`)
const account = this.getAccount(accountId)
if (!account) {
@@ -182,7 +183,7 @@
}
}
},
- "MessageReceived": (accountId, conversationId, message) => {
+ MessageReceived: (accountId, conversationId, message) => {
console.log(`messageReceived: ${accountId} ${conversationId}`)
console.log(message)
const account = this.getAccount(accountId)
@@ -197,7 +198,7 @@
onMessage(account, conversation, message)
}
},
- "ConversationRequestReceived": (accountId, conversationId, request) => {
+ ConversationRequestReceived: (accountId, conversationId, request) => {
console.log(`conversationRequestReceived: ${accountId} ${conversationId}`)
const account = this.getAccount(accountId)
if (!account) {
@@ -205,7 +206,7 @@
return
}
},
- "ConversationMemberEvent": (accountId, conversationId, member, event) => {
+ ConversationMemberEvent: (accountId, conversationId, member, event) => {
console.log(`conversationMemberEvent: ${accountId} ${conversationId}`)
const account = this.getAccount(accountId)
if (!account) {
@@ -213,13 +214,35 @@
return
}
},
- "OnConversationError": (accountId, conversationId, code, what) => {
+ OnConversationError: (accountId, conversationId, code, what) => {
console.log(`onConversationError: ${accountId} ${conversationId}`)
const account = this.getAccount(accountId)
if (!account) {
console.log(`Unknown account ${accountId}`)
return
}
+ },
+ // Calls
+ StateChange: (callId, state, code) => {
+ console.log(`CallStateChange: ${callId} ${state} ${code}`)
+ },
+ IncomingCall: (accountId, callId, peerUri) => {
+ console.log(`IncomingCall: ${accountId} ${callId} ${peerUri}`)
+ },
+ ConferenceCreated: (confId) => {
+ console.log(`ConferenceCreated: ${confId}`)
+ },
+ ConferenceChanged: (confId, state) => {
+ console.log(`ConferenceChanged: ${confId}`)
+
+ },
+ ConferenceRemoved: (confId) => {
+ console.log(`ConferenceRemoved: ${confId}`)
+
+ },
+ onConferenceInfosUpdated: (confId, info) => {
+ console.log(`onConferenceInfosUpdated: ${confId}`)
+
}
})
diff --git a/routes/jami.js b/routes/jami.js
index 28c4a05..32c2d1c 100644
--- a/routes/jami.js
+++ b/routes/jami.js
@@ -155,6 +155,28 @@
}
})
+ // Calls
+
+ accountRouter.get('/calls', async (req, res) => {
+ console.log(`Get calls for account ${req.params.accountId}`)
+ try {
+ const calls = await this.jami.getCalls(req.params.accountId)
+ res.json(calls).end()
+ } catch (e) {
+ res.status(400).json({ error: e.message })
+ }
+ })
+
+ accountRouter.get('/calls/:callId', async (req, res) => {
+ console.log(`Get call ${callId} for account ${req.params.accountId}`)
+ try {
+ const messages = await this.jami.getCall(req.params.accountId, req.params.callId)
+ res.json(messages).end()
+ } catch (e) {
+ res.status(400).json({ error: e.message })
+ }
+ })
+
// Nameserver
const nsRouter = Router({mergeParams: true})
accountRouter.use('/ns', nsRouter) // use account nameserver