summaryrefslogtreecommitdiffstats
path: root/webapp/stores
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-09-16 15:35:13 -0300
committerGitHub <noreply@github.com>2016-09-16 15:35:13 -0300
commit781ff323db4c70e4ca476f9ef13a04e5aa063585 (patch)
treea9dae870d4e750ad87ee0624d8ea859995b0dbf7 /webapp/stores
parentdf2d61d94175369bff5a16242f35cb6d7b62d7fb (diff)
downloadchat-781ff323db4c70e4ca476f9ef13a04e5aa063585.tar.gz
chat-781ff323db4c70e4ca476f9ef13a04e5aa063585.tar.bz2
chat-781ff323db4c70e4ca476f9ef13a04e5aa063585.zip
Webrtc client side (#4026)
* WebRTC Server side * WebRTC client side * Bug fixes and improvements * Pushing UI improvements for webrtc (#3728) * Pushing UI improvements for webrtc * Updating webrtc css * PLT-3943 WebRTC P1: bug fixes and improvements * Video resolution set to std, reduce volume of ringtone and flip video horizontally * Fix calling a user B while WebRTC RHS is still opened * Leave RHS opened when call ends, Fix isBusy on popover and channel_header * Fix pre-release feature, RHS & System Console * PLT-3945 - Updating UI for webrtc (#3908) * PLT-3943 Webrtc p1 * Add ongoing call indicator when RHS is opened * UI updates to to webrtc notifcation (#3959)
Diffstat (limited to 'webapp/stores')
-rw-r--r--webapp/stores/webrtc_store.jsx110
1 files changed, 110 insertions, 0 deletions
diff --git a/webapp/stores/webrtc_store.jsx b/webapp/stores/webrtc_store.jsx
new file mode 100644
index 000000000..8213b15aa
--- /dev/null
+++ b/webapp/stores/webrtc_store.jsx
@@ -0,0 +1,110 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
+import EventEmitter from 'events';
+import {WebrtcActionTypes} from 'utils/constants.jsx';
+
+class WebrtcStoreClass extends EventEmitter {
+ constructor() {
+ super();
+
+ this.video_call_with = null;
+ }
+
+ setVideoCallWith(userId) {
+ this.video_call_with = userId;
+ this.emitBusy(userId !== null);
+ }
+
+ getVideoCallWith() {
+ return this.video_call_with;
+ }
+
+ isBusy() {
+ return this.video_call_with !== null;
+ }
+
+ emitInit(userId, isCaller) {
+ this.emit(WebrtcActionTypes.INITIALIZE, userId, isCaller);
+ }
+
+ addInitListener(callback) {
+ this.on(WebrtcActionTypes.INITIALIZE, callback);
+ }
+
+ removeInitListener(callback) {
+ this.removeListener(WebrtcActionTypes.INITIALIZE, callback);
+ }
+
+ emitBusy(isBusy) {
+ this.emit(WebrtcActionTypes.BUSY, isBusy);
+ }
+
+ addBusyListener(callback) {
+ this.on(WebrtcActionTypes.BUSY, callback);
+ }
+
+ removeBusyListener(callback) {
+ this.removeListener(WebrtcActionTypes.BUSY, callback);
+ }
+
+ emitNotify(message) {
+ this.emit(WebrtcActionTypes.NOTIFY, message);
+ }
+
+ addNotifyListener(callback) {
+ this.on(WebrtcActionTypes.NOTIFY, callback);
+ }
+
+ removeNotifyListener(callback) {
+ this.removeListener(WebrtcActionTypes.NOTIFY, callback);
+ }
+
+ emitChanged(message) {
+ this.emit(WebrtcActionTypes.CHANGED, message);
+ }
+
+ addChangedListener(callback) {
+ this.on(WebrtcActionTypes.CHANGED, callback);
+ }
+
+ removeChangedListener(callback) {
+ this.removeListener(WebrtcActionTypes.CHANGED, callback);
+ }
+
+ emitRhsChanged(isOpen) {
+ this.emit(WebrtcActionTypes.RHS, isOpen);
+ }
+
+ addRhsChangedListener(callback) {
+ this.on(WebrtcActionTypes.RHS, callback);
+ }
+
+ removeRhsChangedListener(callback) {
+ this.removeListener(WebrtcActionTypes.RHS, callback);
+ }
+}
+
+var WebrtcStore = new WebrtcStoreClass();
+WebrtcStore.setMaxListeners(0);
+
+WebrtcStore.dispatchToken = AppDispatcher.register((payload) => {
+ var action = payload.action;
+
+ switch (action.type) {
+ case WebrtcActionTypes.INITIALIZE:
+ WebrtcStore.emitInit(action.user_id, action.is_calling);
+ break;
+ case WebrtcActionTypes.NOTIFY:
+ WebrtcStore.emitNotify(action.message);
+ break;
+ default:
+ if (action.message) {
+ WebrtcStore.emitChanged(action.message);
+ }
+ break;
+ }
+});
+
+export default WebrtcStore; \ No newline at end of file