* 创建一个新的 PeerDataChannel 实例 * @param config 配置
(config: PeerDataChannelConfig = {})
| 42 | * @param config 配置 |
| 43 | */ |
| 44 | constructor(config: PeerDataChannelConfig = {}) { |
| 45 | this.blockSize = config.blockSize || PeerDataChannel.DEFAULT_BLOCK_SIZE |
| 46 | this.eventQueue = new EventQueue(this.onData.bind(this)) |
| 47 | this.pc = new RTCPeerConnection({ iceServers: config.iceServers }) |
| 48 | |
| 49 | this.setupPeerConnection() |
| 50 | |
| 51 | if (config.initializeDataChannel) { |
| 52 | this.initializeDataChannel() |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | private setupPeerConnection(): void { |
| 57 | this.pc.ondatachannel = this.handleDataChannel.bind(this) |
nothing calls this directly
no test coverage detected