Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jsxc/jsxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsualko <klaus@jsxc.org>2021-08-26 00:35:31 +0300
committersualko <klaus@jsxc.org>2021-08-26 00:35:31 +0300
commitcfccd8f4a3d6d8be65413c01dc9f9784a70a04ab (patch)
treec095dcd4833b59d8a942dabb58843e752319192d /src
parenta97f654276b90de55fdc661ee72bb2d0b3c9f9a4 (diff)
fix: jingle message initiation
fix #1028
Diffstat (limited to 'src')
-rw-r--r--src/JID.interface.ts2
-rw-r--r--src/JID.ts4
-rw-r--r--src/plugins/JingleMessageInitiationPlugin.ts24
3 files changed, 21 insertions, 9 deletions
diff --git a/src/JID.interface.ts b/src/JID.interface.ts
index 03587456..babbd75b 100644
--- a/src/JID.interface.ts
+++ b/src/JID.interface.ts
@@ -16,4 +16,6 @@ export interface IJID {
isBare(): boolean;
isServer(): boolean;
+
+ toBareJID(): IJID;
}
diff --git a/src/JID.ts b/src/JID.ts
index fa20a704..d5f09e59 100644
--- a/src/JID.ts
+++ b/src/JID.ts
@@ -53,6 +53,10 @@ export default class JID implements IJID {
return !this.node && this.domain && !this.resource;
}
+ public toBareJID(): IJID {
+ return new JID(this.bare);
+ }
+
private escapeNode(node: string) {
return node
.replace(/^\s+|\s+$/g, '')
diff --git a/src/plugins/JingleMessageInitiationPlugin.ts b/src/plugins/JingleMessageInitiationPlugin.ts
index 9beaba34..dfaf5e39 100644
--- a/src/plugins/JingleMessageInitiationPlugin.ts
+++ b/src/plugins/JingleMessageInitiationPlugin.ts
@@ -19,7 +19,7 @@ import { IJID } from '@src/JID.interface';
const JMI = 'urn:xmpp:jingle-message:0';
-type Actions = 'propose' | 'retract' | 'accept' | 'reject';
+type Actions = 'propose' | 'retract' | 'accept' | 'reject' | 'proceed';
const MIN_VERSION = '4.0.0';
const MAX_VERSION = '99.0.0';
@@ -79,17 +79,23 @@ export default class JingleMessageInitiationPlugin extends AbstractPlugin {
return;
}
+ const ownJID = this.pluginAPI.getConnection().getJID();
+
if (action === 'propose') {
this.calls[sessionId] = this.pluginAPI.getCallManager().onIncomingCall(type, sessionId, peer);
this.calls[sessionId].getState().then(state => {
if (state === CallState.Accepted) {
- this.sendMessage(jid, sessionId, 'accept');
+ this.sendMessage(ownJID.toBareJID(), sessionId, 'accept');
+
+ this.sendMessage(jid, sessionId, 'proceed');
} else if (state === CallState.Declined) {
+ this.sendMessage(ownJID.toBareJID(), sessionId, 'reject');
+
this.sendMessage(jid, sessionId, 'reject');
}
});
- } else if (action === 'retract') {
+ } else if (action === 'retract' || (action === 'accept' && jid.full !== ownJID.full)) {
if (this.calls[sessionId]) {
this.calls[sessionId].abort();
}
@@ -107,7 +113,7 @@ export default class JingleMessageInitiationPlugin extends AbstractPlugin {
const action = element.prop('tagName')?.toString().toLowerCase();
- if (!['propose', 'retract', 'accept', 'reject'].includes(action)) {
+ if (!['propose', 'retract', 'accept', 'reject', 'proceed'].includes(action)) {
return true;
}
@@ -166,14 +172,14 @@ export default class JingleMessageInitiationPlugin extends AbstractPlugin {
this.pendingOutgoingSessionIds.push(sessionId);
- this.sendMessage(contact.getJid(), sessionId, 'propose', descriptions);
+ this.sendMessage(contact.getJid().toBareJID(), sessionId, 'propose', descriptions);
return new Promise(resolve => {
const storage = this.pluginAPI.getSessionStorage();
const hook = (data: { action: Actions; jid: string }) => {
if (data.action === 'retract') {
- this.sendMessage(contact.getJid(), sessionId, 'retract');
- } else if (data?.action === 'accept') {
+ this.sendMessage(contact.getJid().toBareJID(), sessionId, 'retract');
+ } else if (data?.action === 'proceed') {
resolve([contact, type, [new JID(data.jid).resource], sessionId]);
} else if (data?.action === 'reject') {
resolve([contact, type, [], sessionId]);
@@ -208,10 +214,10 @@ export default class JingleMessageInitiationPlugin extends AbstractPlugin {
};
private sendMessage(jid: IJID, sessionId: string, action: 'propose', descriptions?: ('audio' | 'video')[]): void;
- private sendMessage(jid: IJID, sessionId: string, action: 'retract' | 'accept' | 'reject'): void;
+ private sendMessage(jid: IJID, sessionId: string, action: 'retract' | 'accept' | 'proceed' | 'reject'): void;
private sendMessage(jid: IJID, sessionId: string, action, descriptions = []) {
let xmlMsg = $msg({
- to: jid.bare,
+ to: jid.full,
}).c(action, {
xmlns: JMI,
id: sessionId,