update legacy apis

This commit is contained in:
2025-09-01 21:21:45 -04:00
parent bbed095926
commit d0f3af72f6
12 changed files with 160 additions and 63 deletions

View File

@@ -55,7 +55,7 @@ export class Channels {
this.initialize();
}
public async createChannel(name: string, description: string, channelOptions: string[] = []): Promise<Channel> {
public async create(name: string, description: string, channelOptions: string[] = []): Promise<Channel> {
if (!name || name.trim().length === 0) {
throw new ChannelError('Channel name cannot be empty', 'INVALID_NAME');
}
@@ -186,13 +186,41 @@ export class Channels {
return deletedChannel;
}
public clearCache(): void {
this._channelsByAlias.clear();
async getPublishSourceStreamId(channelId: string, retryCount: number = 3): Promise<string | null> {
const retryCountRemaining = retryCount || 3;
const channelMembers = await this.getMembers(channelId);
if (channelMembers.length === 0) {
if (retryCountRemaining > 0) {
return this.getPublishSourceStreamId(channelId, retryCountRemaining - 1);
}
return null;
}
const presenter = channelMembers.find(member => member.role === 'Presenter');
if (!presenter) {
if (retryCountRemaining > 0) {
return this.getPublishSourceStreamId(channelId, retryCountRemaining - 1);
}
return null;
}
const publishSourceStreamIdRegExp = /pcast:\/\/.*\/([^?]*)/;
return presenter.streams[0].uri.match(publishSourceStreamIdRegExp)?.[1] ?? null;
}
public getCacheSize(): number {
return this._channelsByAlias.size;
}
// TODO(AZ): Implement this
// public async fork(channelId: string): Promise<Channel>
// TODO(AZ): Implement this
// public async killChannel(channelId: string): Promise<Channel>
// TODO(AZ): Implement this
// public async publishViaUrl(mediaUriToPublish: string, token: string): Promise<Channel>
private async initialize(): Promise<void> {
try {