Skip to content

Commit

Permalink
chore(bot-handler-avs): Upgrade to avs 6.2 (#3170)
Browse files Browse the repository at this point in the history
* chore(bot-handler-avs): Bump @wireapp/avs from 6.0.46 to 6.2.19

* implement send message

* fix reference error

* Update packages/bot-handler-avs/src/AVSHandler.ts

Co-authored-by: Florian Imdahl <ffflorian@users.noreply.github.com>

* upgrade to new core api

Co-authored-by: Florian Imdahl <ffflorian@users.noreply.github.com>
  • Loading branch information
thisisamir98 and ffflorian authored Aug 12, 2020
1 parent 78cb6b0 commit d25951b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/bot-handler-avs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"@types/webrtc": "0.0.26",
"@wireapp/avs": "6.0.46",
"@wireapp/avs": "6.2.20",
"wrtc": "0.4.6"
},
"description": "Adds audio/video/signaling (AVS) functionality for Wire bots.",
Expand Down
34 changes: 26 additions & 8 deletions packages/bot-handler-avs/src/AVSHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
LOG_LEVEL,
REASON,
Wcall,
WcallClient,
WcallParticipantChangedHandler,
} from '@wireapp/avs';
import axios from 'axios';
Expand Down Expand Up @@ -69,6 +70,7 @@ declare global {
global.RTCPeerConnection = wrtc.RTCPeerConnection;
global.MediaStream = wrtc.MediaStream;
global.MediaStreamTrack = wrtc.MediaStreamTrack;
global.RTCRtpSender = wrtc.RTCRtpSender;
global.navigator = {
...global.navigator,
mediaDevices: {
Expand All @@ -81,6 +83,10 @@ interface InitOptions {
callParticipantChangedHandler?: WcallParticipantChangedHandler;
}

interface SendMessageTarget {
clients: WcallClient[];
}

export class AVSHandler extends MessageHandler {
private wCall?: Wcall;
private wUser?: number;
Expand Down Expand Up @@ -219,17 +225,29 @@ export class AVSHandler extends MessageHandler {
};

private readonly onSendCallMessage = (
ctx: number,
context: number,
conversationId: string,
selfUserId: string,
selfClientId: string,
userid_dest: string | undefined,
clientid_dest: string | undefined,
data: string,
userId: string,
clientId: string,
targets: string | null,
unused: string | null,
payload: string,
): number => {
const userIds: string[] = [];

if (typeof targets === 'string') {
const parsedTargets: SendMessageTarget = JSON.parse(targets);
for (const target of parsedTargets.clients) {
userIds.push(target.userid);
}
}

void (async () => {
const callPayload = this.account!.service!.conversation.messageBuilder.createCall(conversationId, data);
await this.account!.service!.conversation.send(callPayload);
try {
await this.sendCall(conversationId, payload, userIds);
} catch (error) {
console.error('Failed to send targeted message', error);
}
})();

return 0;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3023,10 +3023,10 @@
"@webassemblyjs/wast-parser" "1.9.0"
"@xtuc/long" "4.2.2"

"@wireapp/avs@6.0.46":
version "6.0.46"
resolved "https://registry.npmjs.org/@wireapp/avs/-/avs-6.0.46.tgz#1c8827e9f1b19c27580ec8415ace2763d4ac5afc"
integrity sha512-mokj5DVZWszeznmS9vTW0rUAg5qr8xSm61XwvB14hUCU1GEv2xV1OFhSnd8e3dEb3C3P512sjSDuz4pxN0dhLA==
"@wireapp/avs@6.2.20":
version "6.2.20"
resolved "https://registry.npmjs.org/@wireapp/avs/-/avs-6.2.20.tgz#2b7facac5f8fafca97f3d4e14d458b56d63bf0bc"
integrity sha512-v5n1DbukuwH3sjoD1qkL77IX0mVoygpzPrlzF8Y1ZKvwo5AQ1Fjy+Jsgl3meAwxQ8KbzJEu1yAtoixFpzKMWgA==

"@wireapp/protocol-messaging@1.25.4":
version "1.25.4"
Expand Down

0 comments on commit d25951b

Please sign in to comment.