add connection skeleton (WIP).

This commit is contained in:
Miroslav Šedivý
2021-06-17 09:22:02 +02:00
parent 4497a18793
commit af206457ab
2 changed files with 76 additions and 1 deletions

View File

@ -0,0 +1,70 @@
import EventEmitter from 'eventemitter3'
import { NekoWebSocket } from './websocket'
import { NekoWebRTC, WebRTCStats } from './webrtc'
export interface NekoConnectionEvents {
connecting: () => void
connected: () => void
disconnected: (error?: Error) => void
}
export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
staysConnected = false
websocket = new NekoWebSocket()
webrtc = new NekoWebRTC()
constructor() {
super()
//
// websocket events
//
this.websocket.on('message', async (event: string, payload: any) => {
})
this.websocket.on('connecting', () => {
})
this.websocket.on('connected', () => {
})
this.websocket.on('disconnected', () => {
})
//
// webrtc events
//
this.webrtc.on('track', (event: RTCTrackEvent) => {
})
this.webrtc.on('candidate', (candidate: RTCIceCandidateInit) => {
})
this.webrtc.on('stats', (stats: WebRTCStats) => {
})
this.webrtc.on('connecting', () => {
})
this.webrtc.on('connected', () => {
})
this.webrtc.on('disconnected', () => {
})
}
public async connect(): Promise<void> {
this.staysConnected = true
}
public async disconnect(): Promise<void> {
this.staysConnected = false
}
}