This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
RTCPeerConnection.close()
메소드로 피어 연결을 종료합니다.
Syntax
RTCPeerConnection.close();
이 메소드는 입력 패러미터가 없으며, 반환 값도 없습니다.
이 메소드를 호출하게되면, 모든 진행 중인 ICE 프로세싱 및 활성화된 스트림을 종료하고, RTCPeerConnection
의 ICE 에이전트를 종료합니다. 이 방법으로 ICE 에이전트에 의해 사용되는 리소스들 (TURN 허가 포함) 을 해제시킵니다. 모든 RTCRtpSender
객체들은 이 메소드가 반환되면 정지됩니다. (아직 종료 중인 과정에 있을 수도 있습니다만, 사실상 정지됩니다.)
이 메소드가 반환되면, RTCPeerConnection.signalingState
에 의해 반환된 signaling 상태가 closed
로 됩니다.
같은 원격 유저와의 새로운 연결 생성을 시도하기전에 이전에 존재하던 RTCPeerConnection
의 모든 참조 값들을 delete
하십시오. 삭제되지 않은 참조 값들이 브라우저에서 오류를 초래 할 수 있습니다.
예시
var pc = new RTCPeerConnection();
var dc = pc.createDataChannel("my channel");
dc.onmessage = function (event) {
console.log("received: " + event.data);
pc.close(); // 첫 메세지를 받으면, 연결을 종료
};
dc.onopen = function () {
console.log("datachannel open");
};
dc.onclose = function () {
console.log("datachannel close");
};
명세
명세 | 상태 | 코멘트 |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers The definition of 'RTCPeerConnection.close()' in that specification. |
Candidate Recommendation | Initial specification. |
브라우저 호환성
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.