-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
98 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './mediasoup.slave.js'; | ||
export * from './mediasoup.room.js'; | ||
export * from './media.slave.js'; | ||
export * from './media.room.js'; | ||
export * from './media.peer.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
Entity, | ||
BaseEntity, | ||
CreateDateColumn, | ||
Column, | ||
PrimaryColumn, | ||
ManyToOne, | ||
} from 'typeorm'; | ||
import { MediaSlave } from './media.slave.js'; | ||
import { MediaRoom } from './media.room.js'; | ||
|
||
@Entity() | ||
export class MediaPeer extends BaseEntity { | ||
@PrimaryColumn('uuid') | ||
id!: string; | ||
|
||
@Column('integer') | ||
slaveId!: number; | ||
|
||
@ManyToOne(() => MediaSlave, (slave) => slave.peers, { | ||
onDelete: 'CASCADE', | ||
}) | ||
slave!: MediaSlave; | ||
|
||
@Column('uuid') | ||
roomId!: string; | ||
|
||
@ManyToOne(() => MediaRoom, (room) => room.peers, { onDelete: 'CASCADE' }) | ||
room!: MediaRoom; | ||
|
||
@Column('text') | ||
routerId!: string; | ||
|
||
@Column({ type: 'jsonb', nullable: true }) | ||
metadata?: any; | ||
|
||
@CreateDateColumn() | ||
createDate!: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
import 'node-fetch'; | ||
|
||
import apiRouters from './apis/slave/index.js'; | ||
import { | ||
MediasoupRoomService, | ||
MediasoupSlaveService, | ||
mediasoupWorkerManager, | ||
} from './services/index.js'; | ||
import { SlaveService, mediasoupWorkerManager } from './services/index.js'; | ||
import { startServer, getDataSource } from './utils/index.js'; | ||
|
||
async function bootstrap() { | ||
await startServer(apiRouters); | ||
try { | ||
// remove old room of dead slave | ||
await new MediasoupRoomService(getDataSource()).removeAll(); | ||
await mediasoupWorkerManager.init(); | ||
await new MediasoupSlaveService(getDataSource()).addFromEnv(); | ||
} catch (e) {} | ||
|
||
const slaveService = new SlaveService(getDataSource()); | ||
// remove old room of dead slave | ||
await slaveService.removeCurrent(); | ||
await slaveService.addFromEnv(); | ||
|
||
await mediasoupWorkerManager.init(); | ||
} | ||
|
||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters