diff --git a/app/actions/actionsTypes.ts b/app/actions/actionsTypes.ts index 75f42588c..f80ccdff6 100644 --- a/app/actions/actionsTypes.ts +++ b/app/actions/actionsTypes.ts @@ -84,3 +84,5 @@ export const ENCRYPTION = createRequestTypes('ENCRYPTION', ['INIT', 'STOP', 'DEC export const PERMISSIONS = createRequestTypes('PERMISSIONS', ['SET', 'UPDATE']); export const ROLES = createRequestTypes('ROLES', ['SET', 'UPDATE', 'REMOVE']); +export const VIDEO_CONF = createRequestTypes('VIDEO_CONF', ['HANDLE_INCOMING_WEBSOCKET_MESSAGES']); + diff --git a/app/actions/videoConf.ts b/app/actions/videoConf.ts new file mode 100644 index 000000000..f11bcd052 --- /dev/null +++ b/app/actions/videoConf.ts @@ -0,0 +1,16 @@ +import { Action } from 'redux'; + +import { VIDEO_CONF } from './actionsTypes'; + +export interface IVideoConfGenericAction extends Action { + data: any; +} + +export type TActionUserTyping = IVideoConfGenericAction & Action; + +export function handleVideoConfIncomingWebsocketMessages(data: any): IVideoConfGenericAction { + return { + type: VIDEO_CONF.HANDLE_INCOMING_WEBSOCKET_MESSAGES, + data + }; +} diff --git a/app/lib/methods/subscriptions/rooms.ts b/app/lib/methods/subscriptions/rooms.ts index 443b681f4..182f0a0c2 100644 --- a/app/lib/methods/subscriptions/rooms.ts +++ b/app/lib/methods/subscriptions/rooms.ts @@ -34,6 +34,7 @@ import { E2E_MESSAGE_TYPE } from '../../constants'; import { getRoom } from '../getRoom'; import { merge } from '../helpers/mergeSubscriptionsRooms'; import { getRoomAvatar, getRoomTitle, getSenderName, random } from '../helpers'; +import { handleVideoConfIncomingWebsocketMessages } from '../../../actions/videoConf'; const removeListener = (listener: { stop: () => void }) => listener.stop(); @@ -402,6 +403,11 @@ export default function subscribeRooms() { log(e); } } + + if (/video-conference/.test(ev)) { + const [action, params] = ddpMessage.fields.args; + store.dispatch(handleVideoConfIncomingWebsocketMessages({ action, params })); + } }); const stop = () => { diff --git a/app/sagas/index.js b/app/sagas/index.js index ab9508dfb..12d2ba83f 100644 --- a/app/sagas/index.js +++ b/app/sagas/index.js @@ -13,6 +13,7 @@ import deepLinking from './deepLinking'; import inviteLinks from './inviteLinks'; import createDiscussion from './createDiscussion'; import encryption from './encryption'; +import videoConf from './videoConf'; const root = function* root() { yield all([ @@ -28,7 +29,8 @@ const root = function* root() { inviteLinks(), createDiscussion(), inquiry(), - encryption() + encryption(), + videoConf() ]); }; diff --git a/app/sagas/videoConf.js b/app/sagas/videoConf.js new file mode 100644 index 000000000..c9f9a7b3a --- /dev/null +++ b/app/sagas/videoConf.js @@ -0,0 +1,38 @@ +import { takeLatest } from 'redux-saga/effects'; + +import { VIDEO_CONF } from '../actions/actionsTypes'; + +const handleVideoConfIncomingWebsocketMessages = function* handleVideoConfIncomingWebsocketMessages({ data }) { + const { action, params } = data.action; + + if (!action || typeof action !== 'string') { + return; + } + if (!params || typeof params !== 'object' || !params.callId || !params.uid || !params.rid) { + return; + } + + console.log(action, params); + // switch (action) { + // case 'call': + // return this.onDirectCall(params); + // case 'canceled': + // return this.onDirectCallCanceled(params); + // case 'accepted': + // return this.onDirectCallAccepted(params); + // case 'rejected': + // return this.onDirectCallRejected(params); + // case 'confirmed': + // return this.onDirectCallConfirmed(params); + // case 'join': + // return this.onDirectCallJoined(params); + // case 'end': + // return this.onDirectCallEnded(params); + // } +}; + +const root = function* root() { + yield takeLatest(VIDEO_CONF.HANDLE_INCOMING_WEBSOCKET_MESSAGES, handleVideoConfIncomingWebsocketMessages); +}; + +export default root;