join to existing call in creator app
This commit is contained in:
1 parent
7528f653e9
commit
221c4f595f
9 files changed
+251
-16
No files matched your search
@@ -10,7 +10,7 @@ import {
|
||||
YANDEX_COOKIE_DOMAINS,
|
||||
DION_COOKIE_DOMAINS,
|
||||
} from '../constants';
|
||||
import { TunnelMode, Platform, BotSettings } from '../types';
|
||||
import { TunnelMode, Platform, BotSettings, HeadlessStartArgs } from '../types';
|
||||
|
||||
export function registerIpcHandlers(tabManager: TabManager): void {
|
||||
ipcMain.handle(IPC.GET_HOOK_CODE, async (_e, tabId: string, url: string) => {
|
||||
@@ -33,8 +33,8 @@ export function registerIpcHandlers(tabManager: TabManager): void {
|
||||
tabManager.startRelay(tabId, tab);
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.START_HEADLESS, async (_e, tabId: string, platform: string) => {
|
||||
await tabManager.startHeadless(tabId, platform as Platform);
|
||||
ipcMain.handle(IPC.START_HEADLESS, async (_e, tabId: string, platform: string, args: HeadlessStartArgs) => {
|
||||
await tabManager.startHeadless(tabId, platform as Platform, args);
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.CLOSE_TAB, (_e, tabId: string) => {
|
||||
|
||||
@@ -4,7 +4,17 @@ import { BrowserWindow, session } from 'electron';
|
||||
import * as net from 'net';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs/promises';
|
||||
import { TabState, PortPair, TabListEntry, Platform, TunnelMode, RelayMode, CallStatus } from '../types';
|
||||
import {
|
||||
TabState,
|
||||
PortPair,
|
||||
TabListEntry,
|
||||
Platform,
|
||||
TunnelMode,
|
||||
RelayMode,
|
||||
CallStatus,
|
||||
HeadlessStartArgs,
|
||||
HeadlessMode,
|
||||
} from '../types';
|
||||
import {
|
||||
INITIAL_PORT_BASE,
|
||||
IPC,
|
||||
@@ -273,14 +283,35 @@ export class TabManager {
|
||||
}
|
||||
}
|
||||
|
||||
async startHeadless(tabId: string, platform: Platform): Promise<void> {
|
||||
private joinFlagFor(platform: Platform): string | null {
|
||||
switch (platform) {
|
||||
case Platform.VK:
|
||||
return '--vk-link';
|
||||
case Platform.Telemost:
|
||||
return '--tm-link';
|
||||
case Platform.WBStream:
|
||||
case Platform.Dion:
|
||||
return '--room';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async startHeadless(tabId: string, platform: Platform, args: HeadlessStartArgs): Promise<void> {
|
||||
const tab = await this.getOrCreateTab(tabId);
|
||||
tab.platform = platform;
|
||||
const joinTarget = args.mode === HeadlessMode.Join ? (args.target || '').trim() : '';
|
||||
if (args.mode === HeadlessMode.Join && !joinTarget) {
|
||||
this.sendLog(tabId, 'Join requested but no target link/room provided.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform === Platform.WBStream) {
|
||||
tab.tunnelMode = TunnelMode.HeadlessWBStream;
|
||||
this.killRelay(tabId, tab);
|
||||
const proc = spawn(this.headlessWBStreamPath, ['--resources', 'default'], {
|
||||
const wbArgs = ['--resources', 'default'];
|
||||
if (joinTarget) wbArgs.push('--room', joinTarget);
|
||||
const proc = spawn(this.headlessWBStreamPath, wbArgs, {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
tab.relay = proc;
|
||||
@@ -314,7 +345,12 @@ export class TabManager {
|
||||
this.killRelay(tabId, tab);
|
||||
const cookiesPath = path.join(app.getPath('userData'), `cookies-${platform}.json`);
|
||||
await fs.writeFile(cookiesPath, JSON.stringify(cookies));
|
||||
const proc = spawn(config.binaryPath, ['--resources', 'default', '--cookies', cookiesPath], {
|
||||
const spawnArgs = ['--resources', 'default', '--cookies', cookiesPath];
|
||||
if (joinTarget) {
|
||||
const flag = this.joinFlagFor(platform);
|
||||
if (flag) spawnArgs.push(flag, joinTarget);
|
||||
}
|
||||
const proc = spawn(config.binaryPath, spawnArgs, {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
tab.relay = proc;
|
||||
@@ -330,7 +366,7 @@ export class TabManager {
|
||||
this.sendLog(tabId, `${config.platformName} session rejected (401), clearing and re-prompting login.`);
|
||||
await this.clearAuthCookies(config.cookieDomains, config.authCookie);
|
||||
if (this.tabs.get(tabId) === tab) {
|
||||
this.startHeadless(tabId, platform);
|
||||
this.startHeadless(tabId, platform, args);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user