RTCDataChannel

Dieser Artikel benötigt eine technische Überprüfung. So können Sie helfen.

Dieser Artikel benötigt eine redaktionelle Überprüfung. So können Sie helfen.

Diese Übersetzung ist unvollständig. Bitte helfen Sie, diesen Artikel aus dem Englischen zu übersetzen.

Dies ist eine experimentelle Technologie
Da diese Technologie noch nicht definitiv implementiert wurde, sollte die Browser Kompatibilität beachtet werden. Es ist auch möglich, dass der Syntax in einer späteren Spezifikation noch geändert wird.

Das RTCDataChannel Interface repräsentiert einen bidirektionalen Datenkanal zwischen zwei Endpunkten einer direkten Verbindungen.

Ein Objekt dieses Types kann mit RTCDataChannel.createDataChannel() erstellt, oder als Rückgabewert des Events datachannel als Typ RTCDataChannelEvent bei einer bestehenden RTCPeerConnection zurückgegeben werden.

In Gecko ist die API über DataChannel anstelle des Standard RTCDataChannel namens erreichbar.

Properties

RTCDataChannel.label Read only
Gibt ein DOMString zurück. Dieser beinhaltet den Namen, welcher den Datenkanal beschreibt. Es gibt keine Einschränkung der Einzigartigkeit.
RTCDataChannel.ordered Read only
Gibt ein Boolean zurück, der aussagt ob das Empfangen der Nachricht garantiert ist, oder nicht
RTCDataChannel.protocol Read only
Returns a DOMString containing the name of the subprotocol in use. If none, it returns "".
RTCDataChannel.id Read only
Returns an unsigned short being a unique id for the channel. It is set at the creation of the RTCDataChannel object.
RTCDataChannel.readyState Read only
Returns an enum of the type RTCDataChannelState representing the state of the underlying data connection. It can be one of the following values:
  • "connecting" is the state indicating that the underlying connection is not yet set up and active. This is the initial state of a data channel created with RTCPeerConnection.createDataChannel().
  • "open" is the state indicating that the underlying connection is up and running. This is the initial state of a data channel dispatched in a RTCDataChannelEvent.
  • "closing" is the state indicating that the underlying connection is in the process of shutting down. No new sending task is accepting but the cached messages are in the process of being sent, or received.
  • "closed" is the state indicating that the underlying connection has been shut down (or couldn't be established).
RTCDataChannel.bufferedAmount Read only
Returns an unsigned long containing the amount of bytes that have been queued for sending: that is the amount of data requested to be transmitted via RTCDataChannel.send() that has not been sent yet. Note that if the channel is closed, the buffering continues.
RTCDataChannel.binaryType
Is a DOMString indicating the type of binary data transmitted by the connection. This should be either "blob" if Blob objects are being used or "arraybuffer" if ArrayBuffer objects are being used. Initially it is set to "blob".
RTCDataChannel.maxPacketLifeType Read only
Is an unsigned short indicating the length in milliseconds of the window in when messaging happens in unreliable mode.
RTCDataChannel.maxRetransmits Read only
Is an unsigned short indicating the maximum amount of retransmissions that can happen when messaging happens in unreliable mode.
RTCDataChannel.negotiated Read only
Is a Boolean indicating if the channel has been negotiated by the application, or not.
DataChannel.reliable Read only
Is a Boolean indicating if the connection can send message in unreliable mode.
DataChannel.stream Read only
Is an obsolete synonym for RTCDataChannel.id.

Event Handlers

RTCDataChannel.onopen
Is the event handler called when the open event is received. Such an event is sent when a the underlying data transport, that is the data connection, has been established.
RTCDataChannel.onmessage
Is the event handler called when the message event is received. Such an event is sent when a message is available on the data connection.
RTCDataChannel.onclose
Is the event handler called when the close event is received. Such an event is sent when the underlying data transport has been closed.
RTCDataChannel.onerror
Is the event handler called when the error event is received. Such an event is sent when an error has been encountered.

Methods

RTCDataChannel.close()
Closes the channel. The closing is done in a non abrupt way. The state of the channel is set to "closing", the messages not yet sent are sent, then the channel is closed.
RTCDataChannel.send()
Sends the data in parameter over the channel. The data can be a DOMString, a Blob, an ArrayBuffer or an ArrayBufferView.

Example

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");
};

 

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browser
Die Definition von 'RTCDataChannel' in dieser Spezifikation.
Arbeitsentwurf Initial specification.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Ja) (Ja) [1] Nicht unterstützt (Ja) ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? Nicht unterstützt ? ?

[1] Das Interface heißt DataChannel und nicht RTCDataChannel

Siehe auch

Schlagwörter des Dokuments und Mitwirkende

 Mitwirkende an dieser Seite: Tilli81, Nys
 Zuletzt aktualisiert von: Tilli81,