forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36a0fc3
commit 2880f00
Showing
17 changed files
with
290 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import toastr from 'toastr'; | ||
import { modal } from 'meteor/rocketchat:ui-utils'; | ||
import { t } from 'meteor/rocketchat:utils'; | ||
import { FlowRouter } from 'meteor/kadira:flow-router'; | ||
|
||
export class JitsiCallHandler { | ||
static getAudioElement() { | ||
return document.getElementById('jitsi-sound'); | ||
} | ||
|
||
constructor(payload) { | ||
if (payload === undefined) { | ||
throw new Error('Parameter payload is required'); | ||
} | ||
this.payload = payload; | ||
this.audioElement = JitsiCallHandler.getAudioElement(); | ||
} | ||
|
||
handle() { | ||
if (Meteor.userId() !== this.payload.sender._id) { | ||
this.playIncomeSound(); | ||
this.showIncomeModal(); | ||
} | ||
} | ||
|
||
playIncomeSound() { | ||
this.audioElement.play(); | ||
} | ||
|
||
stopIncomeSound() { | ||
this.audioElement.pause(); | ||
} | ||
|
||
showIncomeModal() { | ||
modal.open({ | ||
title: `${ t('Video_Conference_From') } ${ this.payload.sender.username }`, | ||
text: t('Accept_video_call'), | ||
type: 'warning', | ||
showCancelButton: true, | ||
confirmButtonText: t('Yes'), | ||
cancelButtonText: t('Cancel'), | ||
allowOutsideClick: false, | ||
html: false, | ||
}, () => { | ||
this.goToCallingRoom(); | ||
}, () => { | ||
this.stopIncomeSound(); | ||
this.rejectCall(); | ||
}); | ||
} | ||
|
||
goToCallingRoom() { | ||
this.stopIncomeSound(); | ||
toastr.info('Connecting...'); | ||
FlowRouter.goToRoomByIdWithParams(this.payload.rid, { forceJitsiConnection: 1, jitsiMessage: this.payload._id }); | ||
// after that render room and joinToJitsiConference( messageId ) activate | ||
} | ||
|
||
rejectCall() { | ||
// when someone reject a call, a system message is sent to the room | ||
Meteor.call('jitsi:rejectCall', this.payload.rid); | ||
} | ||
|
||
static rejectCallGlobal() { | ||
JitsiCallHandler.getAudioElement().pause(); | ||
modal.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { JitsiCallHandler } from './JitsiCallHandler'; | ||
|
||
export default function(payload) { | ||
if (payload.message.t === 'jitsi_call_finished_creator') { | ||
JitsiCallHandler.rejectCallGlobal(); | ||
} | ||
if (payload.message.t !== 'jitsi_call_started') { | ||
return; | ||
} | ||
return new JitsiCallHandler(payload); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { TAPi18n } from 'meteor/tap:i18n'; | ||
import { MessageTypes } from 'meteor/rocketchat:ui-utils'; | ||
|
||
Meteor.startup(function() { | ||
MessageTypes.registerType({ | ||
id: 'jitsi_call_rejected', | ||
system: true, | ||
message: TAPi18n.__('Rejected_a_video_call'), | ||
}); | ||
MessageTypes.registerType({ | ||
id: 'jitsi_call_finished_creator', | ||
system: true, | ||
message: TAPi18n.__('Finished_a_video_call_creator'), | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/rocketchat-ui/client/views/app/audioNotificationJitsi.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template name="audioNotificationJitsi"> | ||
<div id="audioNotificationJitsi"> | ||
<audio id="jitsi-sound" preload loop> | ||
<source src="sounds/sound-call.mp3" type="audio/mpeg" /> | ||
</audio> | ||
</div> | ||
</template> |
Oops, something went wrong.