This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

RTCDataChannelEvent()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2020년 1월⁩.

Experimental: 이 기능은 실험적인 기능입니다.
프로덕션 환경에서 사용하기 전에 브라우저 호환성 표를 주의 깊게 확인하세요.

RTCDataChannelEvent() 생성자는 새로운 RTCDataChannelEvent를 생성합니다.

참고 : 이 이벤트는 알아서 WebRTC 레이어에 생성되고 전달되기 때문에, RTCDataChannelEvent를 수동으로 생성하는 일은 거의 없습니다.

Syntax

js
var event = new RTCDataChannelEvent(type, RtcDataChannelEventInit);

패러미터

type

이벤트의 이름을 알려주는 DOMString입니다. 이름은 RTCDataChannelEvent 타입의 한 종류인 "datachannel" 딱 한 가지만 존재합니다.

RtcDataChannelEventInit

아래의 필드를 가지는 RTCDataChannelEventInit 딕셔너리 입니다:* "channel"RTCDataChannel의 한 종류로, 이벤트에 의해 데이터 채널이 확인되었다는 것을 알려줍니다.

  • "bubbles"은 옵션으로 설정이 가능하며, EventInit에서 상속됩니다. 이는 해당 이벤트가 무조건 bubble이 되어야하는지의 여부를 알려줍니다. 기본 값은 false입니다
  • "cancelable"은 옵션으로 설정이 가능하며, EventInit에서 상속됩니다. 이는 해당 이벤트가 취소 될 수 있는지의 여부를 알려줍니다. 기본 값은 false입니다.

명시한대로 설정된 신규 RTCDataChannelEvent 입니다.

예시

아래 예제는 신규 datachannel를 생성합니다. dc는 이미 존재하는 데이터 채널을 뜻합니다.

js
var event = new RTCDataChannelEvent("datachannel", { channel: dc });

명세

Specification
WebRTC: Real-Time Communication in Browsers
# dom-rtcdatachannelevent-constructor

브라우저 호환성

참조