mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add connection skeleton (WIP).
This commit is contained in:
70
src/component/internal/connection.ts
Normal file
70
src/component/internal/connection.ts
Normal 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user