Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Screenshare] Migration to Zoom #846

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from
Draft
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
8 changes: 0 additions & 8 deletions deployment/configurations/node/sage3-prod.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@

// External Services
"services": {
"twilio": {
// Your Account SID from www.twilio.com/console
"accountSid": "",
// API Key
"apiKey": "",
// API Secret
"apiSecret": ""
},
"openai": {
// API Key
"apiKey": "",
Expand Down
12 changes: 6 additions & 6 deletions webstack/apps/homebase/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import * as dns from 'node:dns';

// Websocket
import { WebSocket } from 'ws';
import { SAGEnlp, SAGEPresence, SubscriptionCache } from '@sage3/backend';
import { SAGEnlp, SAGEPresence, SAGEZoomJWTHelper, SubscriptionCache } from '@sage3/backend';
import { setupWsforLogs } from './api/routers/custom';

// YJS
Expand Down Expand Up @@ -53,7 +53,6 @@ import { APIClientWSMessage, ServerConfiguration } from '@sage3/shared/types';
import { SBAuthDB, JWTPayload } from '@sage3/sagebase';

// SAGE Twilio Helper Import
import { SAGETwilio } from '@sage3/backend';
import * as express from 'express';

// Exception handling
Expand Down Expand Up @@ -124,17 +123,18 @@ async function startServer() {
// Load all the models: user, board, ...
await loadCollections();

// Twilio Setup
// Zoom Setup
const screenShareTimeLimit = 3600 * 6 * 1000; // 6 hours
const twilio = new SAGETwilio(config.services.twilio, AppsCollection, PresenceCollection, 10000, screenShareTimeLimit);
app.get('/twilio/token', SAGEBase.Auth.authenticate, (req, res) => {
const zoom = new SAGEZoomJWTHelper(config.services.zoom, AppsCollection, PresenceCollection, 10000, screenShareTimeLimit);
app.get('/zoom/token', SAGEBase.Auth.authenticate, (req, res) => {
console.log('Zoom> token request');
const authId = req.user.id;
if (authId === undefined) {
res.status(403).send();
}
const room = req.query.room as string;
const identity = req.query.identity as string;
const token = twilio.generateVideoToken(identity, room);
const token = zoom.generateVideoToken(identity, room);
res.send({ token });
});

Expand Down
2 changes: 1 addition & 1 deletion webstack/apps/webapp/proxy.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"secure": false,
"ws": true
},
"/twilio": {
"/zoom": {
"target": "http://127.0.0.1:3333",
"secure": false,
"ws": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function Background(props: BackgroundProps) {
const newApp = (type: AppName, x: number, y: number) => {
if (!user) return;
if (type === 'Screenshare') {
createApp(setupApp('', type, x, y, props.roomId, props.boardId, { w: 1280, h: 720 }, { accessId }));
createApp(setupApp('', type, x, y, props.roomId, props.boardId, { w: 1280, h: 720 }));
} else {
createApp(setupApp('', type, x, y, props.roomId, props.boardId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
BoardContextMenu,
ClearBoardModal,
AppToolbar,
Twilio,
LassoToolbar,
Controller,
AssetsPanel,
Expand All @@ -49,6 +48,7 @@ import {
PresenceFollow,
BoardTitle,
KernelsPanel,
Zoom,
} from './components';

type UILayerProps = {
Expand Down Expand Up @@ -102,7 +102,7 @@ export function UILayer(props: UILayerProps) {
const { isOpen: alfredIsOpen, onOpen: alredOnOpen, onClose: alfredOnClose } = useDisclosure();

// Connect to Twilio only if there are Screenshares or Webcam apps
const twilioConnect = apps.filter((el) => el.data.type === 'Screenshare').length > 0;
const zoomConnect = apps.filter((el) => el.data.type === 'Screenshare').length > 0;

/**
* Clear the board confirmed
Expand Down Expand Up @@ -294,7 +294,7 @@ export function UILayer(props: UILayerProps) {
<ClearBoardModal onClick={onClearConfirm} onClose={clearOnClose} isOpen={clearIsOpen}></ClearBoardModal>
</Modal>

<Twilio roomName={props.boardId} connect={twilioConnect} />
<Zoom sessionId={props.boardId} connect={zoomConnect} />

<Controller boardId={props.boardId} roomId={props.roomId} plugins={config.features ? config.features.plugins : false} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export function BoardContextMenu(props: ContextProps) {
if (appName === 'Screenshare') {
width = 1280;
height = 720;
state.accessId = accessId;
}
if (appName === 'Webview') {
height = 650;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export function ApplicationsPanel(props: ApplicationProps) {
} else if (appName === 'Screenshare') {
w = 1280;
h = 720;
state.accessId = accessId;
}

const title = appName == 'Stickie' ? user.data.name : ''; // Gross
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
* the file LICENSE, distributed as part of this software.
*/

import { useTwilioStore, useUser } from '@sage3/frontend';
import { useUser, useZoomStore } from '@sage3/frontend';
import { useEffect } from 'react';

export function Twilio(props: { roomName: string; connect: boolean }) {
export function Zoom(props: { sessionId: string; connect: boolean }) {
// User information
const { user, accessId } = useUser();

// Twilio Store to join and leave room when joining board
const { joinRoom, leaveRoom } = useTwilioStore((state) => state);
const { joinRoom, leaveRoom } = useZoomStore((state) => state);

// Handle joining and leaving twilio room when entering board
// Handle joining and leaving Zoom room when entering board
useEffect(() => {
// Join Twilio room
if (user && props.connect) {
joinRoom(user._id, accessId, props.roomName);
joinRoom(user._id, props.sessionId);
}
// Uncmounting
return () => {
// Leave twilio room
// Leave Zoom room
leaveRoom();
};
}, []);

// Handle joining and leaving twilio room when props.connect changes
// Handle joining and leaving Zoom room when props.connect changes
useEffect(() => {
if (user && props.connect) {
joinRoom(user?._id, accessId, props.roomName);
joinRoom(user?._id, props.sessionId);
} else {
leaveRoom();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export * from './BoardContextMenu';
export * from './ClearBoardModal';
export * from './LassoToolbar';
export * from './Panels';
export * from './Twilio';
export * from './PresenceFollow';
export * from './BoardTitle';
export * from './Zoom';
74 changes: 37 additions & 37 deletions webstack/libs/applications/src/lib/apps.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[
"AIPane",
"BoardLink",
"CSVViewer",
"ChartGenerator",
"Chat",
"Clock",
"Cobrowse",
"CodeEditor",
"Counter",
"DeepZoomImage",
"EChartsViewer",
"GLTFViewer",
"HCDP",
"IFrame",
"ImageViewer",
"JupyterLab",
"LeafLet",
"Linker",
"MapGL",
"Notepad",
"PDFResult",
"PDFViewer",
"PluginApp",
"Poll",
"RTCChat",
"SageCell",
"Seer",
"SensorOverview",
"Stickie",
"TLDraw",
"TwilioScreenshare",
"VegaLite",
"VegaLiteViewer",
"VideoViewer",
"WebpageLink",
"Webview"
]
"AIPane",
"BoardLink",
"CSVViewer",
"ChartGenerator",
"Chat",
"Clock",
"Cobrowse",
"CodeEditor",
"Counter",
"DeepZoomImage",
"EChartsViewer",
"GLTFViewer",
"HCDP",
"IFrame",
"ImageViewer",
"JupyterLab",
"LeafLet",
"Linker",
"MapGL",
"Notepad",
"PDFResult",
"PDFViewer",
"PluginApp",
"Poll",
"RTCChat",
"SageCell",
"Seer",
"SensorOverview",
"Stickie",
"TLDraw",
"ZoomScreenshare",
"VegaLite",
"VegaLiteViewer",
"VideoViewer",
"WebpageLink",
"Webview"
]
Loading