diff --git a/.env.example b/.env.example index 11998ca..3f4108b 100644 --- a/.env.example +++ b/.env.example @@ -12,11 +12,6 @@ PORTALS_API_URL=http://localhost:5000 # This should the same secure key in @cryb/portals/.env under 'API_KEY' PORTALS_API_KEY=api-portals-key -# The base WS endpoint that is used to talk to @cryb/aperture which is sent to the client via WS once the stream is ready -APERTURE_WS_URL=ws://localhost:9001 -# This should be the same secure key in @cryb/aperture/.env under 'APERTURE_KEY' -APERTURE_WS_KEY=api-aperture-key - # Optional: the base URL of @cryb/auth. This service usually runs on port 4500 # AUTH_BASE_URL=http://localhost:4500 diff --git a/README.md b/README.md index a2cd58f..e82d723 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,6 @@ The following services need to be installed for `@cryb/api` to function: We recommend that you run the following services alongside `@cryb/api`, but it's not required. * `@cryb/portals` -* `@cryb/aperture` You also need to install the required dependencies by running `yarn`. @@ -92,7 +91,7 @@ Make sure that you have installed MongoDB and Redis, and they are both running l The command to start MongoDB is `mongod`, and the command to start Redis is `redis-server`. Most Linux distributions will have those packaged, and will start automatically with your system. -If you're developing a feature that requires the VM infrastructure, then make sure `@cryb/portals` and `@cryb/aperture` are running. +If you're developing a feature that requires the VM infrastructure, then make sure `@cryb/portals` and Janus WebRTC server are running. #### Starting @cryb/api diff --git a/src/controllers/internal.controller.ts b/src/controllers/internal.controller.ts index 29ad963..2e10a09 100644 --- a/src/controllers/internal.controller.ts +++ b/src/controllers/internal.controller.ts @@ -7,7 +7,6 @@ import { PortalAllocationStatus } from '../models/room/defs' import WSMessage from '../server/websocket/models/message' import authenticate from '../server/middleware/authenticate.internal.middleware' -import { signApertureToken } from '../utils/aperture.utils' import { handleError, RoomNotFound } from '../utils/errors.utils' const app = express() @@ -32,7 +31,7 @@ app.post('/portal', authenticate, async (req, res) => { * Existing Portal Status Update */ app.put('/portal', authenticate, async (req, res) => { - const { id, status, janusId, janusIp } = req.body as { id: string; status: PortalAllocationStatus; janusId?: number; janusIp?: string } + const { id, status, janusId } = req.body as { id: string; status: PortalAllocationStatus; janusId?: number } // console.log('recieved', id, status, 'from portal microservice, finding room...') try { @@ -43,28 +42,21 @@ app.put('/portal', authenticate, async (req, res) => { // console.log('room found, updating status...') const room = new Room(doc) - const { portal: allocation } = await room.updatePortalAllocation({ janusId, janusIp, status }), + const { portal: allocation } = await room.updatePortalAllocation({ janusId, status }), { online } = await room.fetchOnlineMemberIds() // console.log('status updated and online members fetched:', online) if (online.length > 0) { /** - * Broadcast allocation to all online clients - */ + * Broadcast allocation to all online clients + */ const updateMessage = new WSMessage(0, allocation, 'PORTAL_UPDATE') await updateMessage.broadcast(online) if (status === 'open') { - // JanusId is -1 when a janus instance is not running. - if (allocation.janusId === -1) { - const token = signApertureToken(id), - apertureMessage = new WSMessage(0, { ws: process.env.APERTURE_WS_URL, t: token }, 'APERTURE_CONFIG') - await apertureMessage.broadcast(online) - } else { - const janusMessage = new WSMessage(0, { id: janusId }, 'JANUS_CONFIG') - await janusMessage.broadcast(online) - } + const janusMessage = new WSMessage(0, { id: janusId }, 'JANUS_CONFIG') + await janusMessage.broadcast(online) } } diff --git a/src/models/room/defs.ts b/src/models/room/defs.ts index 706bdaf..56bcd40 100644 --- a/src/models/room/defs.ts +++ b/src/models/room/defs.ts @@ -26,8 +26,7 @@ export type PortalAllocationStatus = export interface IPortalAllocation { id?: string - janusId?: number, - janusIp?: string, + janusId?: number, status: PortalAllocationStatus lastUpdatedAt?: number diff --git a/src/models/room/index.ts b/src/models/room/index.ts index 3cd15b7..ac54403 100644 --- a/src/models/room/index.ts +++ b/src/models/room/index.ts @@ -279,8 +279,7 @@ export default class Room { try { const allocation: IPortalAllocation = { id, - janusId: 1, - janusIp: '0.0.0.0', + janusId: -1, status: 'creating', lastUpdatedAt: Date.now() } diff --git a/src/schemas/room.schema.ts b/src/schemas/room.schema.ts index b988f59..21b8926 100644 --- a/src/schemas/room.schema.ts +++ b/src/schemas/room.schema.ts @@ -12,7 +12,6 @@ const RoomSchema = new Schema({ portal: { id: String, janusId: Number, - janusIp: String, status: String, lastUpdatedAt: String diff --git a/src/server/websocket/models/event.ts b/src/server/websocket/models/event.ts index 14f991c..aeafabf 100644 --- a/src/server/websocket/models/event.ts +++ b/src/server/websocket/models/event.ts @@ -15,7 +15,6 @@ type WSEventIncomingMouseEventType = type WSEventEmittingType = 'JANUS_CONFIG' | -'APERTURE_CONFIG' | 'ROOM_DESTROY' | 'MESSAGE_CREATE' | 'MESSAGE_DESTROY' | diff --git a/src/server/websocket/models/socket.ts b/src/server/websocket/models/socket.ts index 476794f..d0eacd0 100644 --- a/src/server/websocket/models/socket.ts +++ b/src/server/websocket/models/socket.ts @@ -11,7 +11,6 @@ import User from '../../../models/user' import client from '../../../config/redis.config' import config from '../../../config/defaults' -import { signApertureToken } from '../../../utils/aperture.utils' import { verifyToken } from '../../../utils/generate.utils' import { extractUserId, UNALLOCATED_PORTALS_KEYS } from '../../../utils/helpers.utils' import log from '../../../utils/log.utils' @@ -87,14 +86,8 @@ export default class WSSocket { room.createPortal() }) } else if (room.portal.id) { - //JanusId is -1 when a janus instance is not running. - if(room.portal.janusId == -1) { - const token = signApertureToken(room.portal.id), apertureMessage = new WSMessage(0, { ws: process.env.APERTURE_WS_URL, t: token }, 'APERTURE_CONFIG') - apertureMessage.broadcast([ extractUserId(user) ]) - } else { - const janusMessage = new WSMessage(0, { id: room.portal.janusId, ip: room.portal.janusIp }, 'JANUS_CONFIG') - janusMessage.broadcast([ extractUserId(user) ]) - } + const janusMessage = new WSMessage(0, { id: room.portal.janusId }, 'JANUS_CONFIG') + janusMessage.broadcast([ extractUserId(user) ]) } } diff --git a/src/utils/aperture.utils.ts b/src/utils/aperture.utils.ts deleted file mode 100644 index 81973b8..0000000 --- a/src/utils/aperture.utils.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { sign } from 'jsonwebtoken' - -export const signApertureToken = (portalId: string) => sign({ id: portalId }, process.env.APERTURE_WS_KEY, { expiresIn: '1m' })