generated from tailored/router-db-template
init videos volcengine
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import WebSocket from 'ws';
|
||||
// import WebSocket from 'ws';
|
||||
import { initWs } from '../../ws/index.ts';
|
||||
|
||||
type VideoWSOptions = {
|
||||
url?: string;
|
||||
@@ -27,15 +28,17 @@ export class VideoWS {
|
||||
isFile?: boolean;
|
||||
onConnect?: () => void;
|
||||
constructor(options?: VideoWSOptions) {
|
||||
this.ws =
|
||||
options?.ws ||
|
||||
new WebSocket(options.url, {
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
this.itn = options?.itn || false;
|
||||
this.mode = options?.mode || 'online';
|
||||
this.isFile = options?.isFile || false;
|
||||
|
||||
this.initWs(options);
|
||||
}
|
||||
async initWs(options: VideoWSOptions) {
|
||||
if (options?.ws) {
|
||||
this.ws = options.ws;
|
||||
} else {
|
||||
this.ws = await initWs(options.url);
|
||||
}
|
||||
this.onConnect = options?.onConnect || (() => {});
|
||||
this.ws.onopen = this.onOpen.bind(this);
|
||||
this.ws.onmessage = this.onMessage.bind(this);
|
||||
|
||||
Reference in New Issue
Block a user