aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/api/rtcdatachannel/index.html
blob: 84f02d82d5528ed1ec42dcc76714f4a11b4bc04a (plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
title: RTCDataChannel
slug: Web/API/RTCDataChannel
tags:
  - Compatibilidade
  - Navegadores
  - Referencia
translation_of: Web/API/RTCDataChannel
---
<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p>

<p>A interface RTCDataChannel representa um canal de rede que pode ser usado para transferências bidirecionais de dados arbitrários de ponto a ponto. Todo canal de dados está associado a {{domxref("RTCPeerConnection")}}, e cada conexão de pares pode ter até um máximo teórico de 65,534 canais de dados (o limite real pode variar de navegador para navegador).</p>

<p>Para criar um canal de dados e pedir a um ponto remoto para se juntar a você, chame os metodos {{domxref("RTCPeerConnection")}}'s {{domxref("RTCPeerConnection.createDataChannel", "createDataChannel()")}}.  O interlocutor que está sendo convidado a trocar dados recebe um evento {{event("datachannel")}} (que possui o tipo {{domxref("RTCDataChannelEvent")}}) para informá-lo de que o canal de dados foi adicionado à conexão.</p>

<p>{{InterfaceOverview("WebRTC")}}</p>

<h2 id="Exemplo">Exemplo</h2>

<pre class="brush: js">var pc = new RTCPeerConnection();
var dc = pc.createDataChannel("my channel");

dc.onmessage = function (event) {
  console.log("received: " + event.data);
};

dc.onopen = function () {
  console.log("datachannel open");
};

dc.onclose = function () {
  console.log("datachannel close");
};
</pre>

<h2 id="Specifications" name="Specifications">Especificações</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Especificação</th>
   <th scope="col">Status</th>
   <th scope="col">Comentário</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('WebRTC 1.0', '#idl-def-RTCDataChannel', 'RTCDataChannel') }}</td>
   <td>{{ Spec2('WebRTC 1.0') }}</td>
   <td>Especificação inicial</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>

<p>{{ CompatibilityTable }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Característica</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>{{ CompatVersionUnknown }}</td>
   <td>{{ CompatGeckoDesktop(22) }} [1]</td>
   <td>{{ CompatNo }}</td>
   <td>{{ CompatVersionUnknown }}</td>
   <td>{{ CompatUnknown }}</td>
  </tr>
  <tr>
   <td><code>onbufferedamountlow</code></td>
   <td>{{CompatChrome(56)}}</td>
   <td>{{ CompatNo }}</td>
   <td>{{ CompatNo }}</td>
   <td>{{CompatOpera(43)}}</td>
   <td>{{ CompatNo }}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Característica</th>
   <th>Android Webview</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome(29)}}</td>
   <td>{{CompatChrome(29)}}</td>
   <td>{{ CompatGeckoMobile(22) }} [1]</td>
   <td>{{ CompatNo }}</td>
   <td>{{ CompatVersionUnknown }}</td>
   <td>{{ CompatNo }}</td>
  </tr>
  <tr>
   <td><code>onbufferedamountlow</code></td>
   <td>{{CompatChrome(56)}}</td>
   <td>{{CompatChrome(56)}}</td>
   <td>{{ CompatNo }}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatOperaMobile(43)}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] A interface é chamada DataChannel e não RTCDataChannel no Firefox. No entanto, uma ligação foi implementada desde o Firefox 24 para que qualquer um dos nomes funcione.</p>

<h2 id="Veja_também">Veja também</h2>

<ul>
 <li><a href="/en-US/docs/Web/Guide/API/WebRTC">WebRTC</a></li>
</ul>