работаем бля работаем
This commit is contained in:
33
server/plugins/socket/webrtc/ChannelManager.ts
Normal file
33
server/plugins/socket/webrtc/ChannelManager.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { Router } from 'mediasoup/types'
|
||||
import type { Channel as DbChannel } from '../../../prisma/generated-client/client.ts'
|
||||
import { Channel } from './Channel.ts'
|
||||
|
||||
export class ChannelManager {
|
||||
private channels = new Map<string, Channel>()
|
||||
private mediasoupRouter: Router
|
||||
|
||||
constructor(mediasoupRouter: Router) {
|
||||
this.mediasoupRouter = mediasoupRouter
|
||||
}
|
||||
|
||||
async create(newChannel: Channel | DbChannel) {
|
||||
if (newChannel instanceof Channel) {
|
||||
this.channels.set(newChannel.id, newChannel)
|
||||
}
|
||||
else {
|
||||
this.channels.set(newChannel.id, await Channel.create(newChannel.id, newChannel.persistent, this.mediasoupRouter))
|
||||
}
|
||||
}
|
||||
|
||||
get(id: string) {
|
||||
return this.channels.get(id)
|
||||
}
|
||||
|
||||
delete(id: string) {
|
||||
this.channels.delete(id)
|
||||
}
|
||||
|
||||
get all() {
|
||||
return Array.from(this.channels.values())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user