Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add support for Jitsi screensharing in electron app #1355

Merged
merged 6 commits into from
Sep 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/BasePlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ export default class BasePlatform {

isElectron(): boolean { return false; }

setupScreenSharingForIframe() {
}

/**
* Restarts the application, without neccessarily reloading
* any application code
Expand Down
25 changes: 25 additions & 0 deletions src/components/views/elements/AppTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
import url from 'url';
import React from 'react';
import MatrixClientPeg from '../../../MatrixClientPeg';
import PlatformPeg from '../../../PlatformPeg';
import ScalarAuthClient from '../../../ScalarAuthClient';
import SdkConfig from '../../../SdkConfig';
import Modal from '../../../Modal';
Expand Down Expand Up @@ -127,6 +128,30 @@ export default React.createClass({
loading: false,
});
});
window.addEventListener('message', this._onMessage, false);
},

componentWillUnmount() {
window.removeEventListener('message', this._onMessage);
},

_onMessage(event) {
if (this.props.type !== 'jitsi') {
return;
}
if (!event.origin) {
event.origin = event.originalEvent.origin;
}

if (!this.state.widgetUrl.startsWith(event.origin)) {
return;
}

if (event.data.widgetAction === 'jitsi_iframe_loaded') {
const iframe = this.refs.appFrame.contentWindow
.document.querySelector('iframe[id^="jitsiConferenceFrame"]');
PlatformPeg.get().setupScreenSharingForIframe(iframe);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method should exist in all platforms, so impl in BasePlatform as a no-op so other platforms inherit it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it did, you wouldn't need the isElectron check above :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbkr - which is preferred? Implement the method in all platforms and just leave it as a stub in every platform other than electron? I would guess so. Alternatively checking if the function exists and is a function could be a compromise...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbkr says the former.

}
},

_canUserModify: function() {
Expand Down