1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
---
title: RTCPeerConnection.setConfiguration()
slug: Web/API/RTCPeerConnection/setConfiguration
translation_of: Web/API/RTCPeerConnection/setConfiguration
---
<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p>
<p><strong><code>RTCPeerConnection.setConfiguration()</code></strong> 메소드는 {{domxref("RTCConfiguration")}}객체에 명시한 값을 가지고 {{domxref("RTCPeerConnection")}}의 현재 설정을 지정합니다. 이 메소드를 사용해서 연결에서 사용되는 ICE 서버와 전송 정책을 변경 할 수 있습니다. </p>
<p>가장 보편적으로 쓰이는 방법은 사용하려는 ICE 서버 값으로 교체해주는것 입니다. (엄청 자주 사용되는 케이스는 아닐 것입니다) 이 방법을 수행하는 두 가지 시나리오는 아래와 같습니다:</p>
<ul>
<li>{{domxref("RTCPeerConnection")}}가 ICE 서버를 명시하지 않고 시작된 경우. 예를 들어, {{domxref("RTCPeerConnection.RTCPeerConnection()", "RTCPeerConnection()")}} 생성자를 매개변수 없이 호출하게되면, 개발자가 직접 <code>setConfiguration()</code>를 호출해서 ICE 협상 시작 전에 ICE 서버를 추가해줘야 합니다.</li>
<li>연결의 재협상이 필요하거나, 어떤 이유로 인해서 다른 종류의 ICE 서버를 사용해야하는 경우. 예를 들어, 사용자가 새로운 지역으로 이동을 했기 때문에 지역 ICE 서버를 바꿔야하는 경우입니다. 이런 경우에는, <code>setConfiguration()</code>를 호출해서 신규 지역 ICE 서버로 바꿔주고, <a href="/en-US/docs/Web/API/WebRTC_API/Session_lifetime#ICE_restart">ICE restart</a>을 시작하게됩니다.</li>
</ul>
<div class="note">
<p>연결이 이미 설정이 되어있다면, 식별 정보는 변경 할 수 없습니다.</p>
</div>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox"><em>RTCPeerConnection</em>.setConfiguration(<em>configuration</em>);</pre>
<h3 class="syntaxbox" id="매개변수">매개변수</h3>
<dl>
<dt><code>configuration</code></dt>
<dd>설정을 할 수 있는 옵션들을 제공해주는 {{domxref("RTCConfiguration")}} 객체입니다. 변경사항은 계속해서 추가되지 않습니다. 대신에, 신규 값이 기존의 값은 완전히 대체하게 됩니다.</dd>
</dl>
<h3 id="예외처리">예외처리</h3>
<dl>
<dt><code>InvalidAccessError</code></dt>
<dd><code>configuration.iceServers</code>에 정의한 하나 혹은 여러개의 URL이 {{Glossary("TURN")}} 서버 입니다. 하지만, 로그인을 위한 정보가 완전히 제공되지 않아서 발생하는 에러입니 ({{domxref("RTCIceServer.username")}} 혹은 {{domxref("RTCIceServer.credentials")}}의 값이 없다는 뜻). 이로인해 서버에 로그인을 성공적으로 할 수 없게 됩니다.</dd>
<dt><code>InvalidModificationError</code></dt>
<dd><code>configuration</code>에서 변경되는 식별 정보를 포함하고 있지만, 연결을 구성하면서 이미 식별 정보를 지정했기 때문에 발생하는 에러입니다. 이 에러는 <code>configuration.peerIdentity</code> 혹은 <code>configuration.certificates</code>가 설정이 되어있고, 이 값들이 현재 설정 값과 다르기 때문에 발생합니다.</dd>
<dt><code>InvalidStateError</code></dt>
<dd>{{domxref("RTCPeerConnection")}}이 닫혀있어서 발생하는 에러입니다.</dd>
<dt><code>SyntaxError</code></dt>
<dd><code>configuration.iceServers</code>에 제공된 하나 혹은 여러개의 URL 리스트가 유효하지 않아서 발생하는 에러입니다.</dd>
</dl>
<h2 id="예시">예시</h2>
<p>아래의 예시에서는 ICE 재시작이 필요한 것을 확인하고, 다른 ICE 서버를 사용해서 협상이 이루어지도록 합니다.</p>
<pre class="brush: js">var restartConfig = { iceServers: [{
urls: "turn:asia.myturnserver.net",
username: "allie@oopcode.com",
credential: "topsecretpassword"
}]
};
myPeerConnection.setConfiguration(restartConfig);
myPeerConnection.createOffer({"iceRestart": true}).then(function(offer) {
return myPeerConnection.setLocalDescription(offer);
})
.then(function() {
// send the offer to the other peer using the signaling server
})
.catch(reportError);</pre>
<p>먼저, 신규 {{domxref("RTCConfiguration")}}가 신규 ICE 서버와 인증 정보를 명시한 <code>restartConfig</code>를 가지도록 생성됩니다. 그리고 설정한 {{domxref("RTCConfiguration")}}가 <code>setConfiguration()</code>에 전달됩니다. <code>iceRestart</code> 옵션의 값을 <code>true</code>로 지정하고, {{domxref("RTCPeerConnection.createOffer()", "createOffer()")}}을 호출해서 ICE 협상이 재시작됩니다. 이후에, 반환받은 offer를 local description으로 설정하고, 다른 피어에게 offer를 전달하는 것과 같이 일반적으로 진행되도록 처리합니다. </p>
<h2 id="사양서">사양서</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">사양서</th>
<th scope="col">상태</th>
<th scope="col">코멘트</th>
</tr>
<tr>
<td>{{SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-setConfiguration-void-RTCConfiguration-configuration', 'setConfiguration()')}}</td>
<td>{{Spec2('WebRTC 1.0')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="브라우저_호환성">브라우저 호환성</h2>
<div>
<p>{{Compat("api.RTCPeerConnection.setConfiguration")}}</p>
</div>
<h2 id="참조">참조</h2>
<ul>
<li>{{domxref("RTCPeerConnection.getConfiguration()")}}</li>
<li>{{domxref("RTCConfiguration")}}</li>
<li>{{domxref("RTCPeerConnection")}}</li>
</ul>
|