# class PeerConnection

#### package js.html.rtc

#### extends EventTarget

Available on HTML5

The `RTCPeerConnection` interface represents a WebRTC connection between the local computer and a remote peer. It provides methods to connect to a remote peer, maintain and monitor the connection, and close the connection once it's no longer needed.

Documentation RTCPeerConnection by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection

### Constructor

###

`new (?configuration:Configuration, ?constraints:Dynamic)`

Throws:

`null` | DOMError

### Variables

###

`read onlycanTrickleIceCandidates:Bool`

###

`read onlyiceConnectionState:IceConnectionState`

###

`read onlyiceGatheringState:IceGatheringState`

###

`read onlyidpLoginUrl:String`

###

`read onlylocalDescription:SessionDescription`

###

`onaddstream:Function`

###

`onaddtrack:Function`

###

`ondatachannel:Function`

###

`onicecandidate:Function`

###

`oniceconnectionstatechange:Function`

###

`onnegotiationneeded:Function`

###

`onremovestream:Function`

###

`onsignalingstatechange:Function`

###

`ontrack:Function`

###

`read onlypeerIdentity:Promise<IdentityAssertion>`

###

`read onlyremoteDescription:SessionDescription`

###

`read onlysignalingState:SignalingState`

### Methods

###

`addIceCandidate (candidate:IceCandidate, successCallback:Void ‑> Void, failureCallback:DOMError ‑> Void):Promise<Void>`

`addIceCandidate (candidate:IceCandidate):Promise<Void>`

###

`addStream (stream:MediaStream):Void`

###

`addTrack (track:MediaStreamTrack, stream:MediaStream, moreStreams:Rest<MediaStream>):RtpSender`

###

`close ():Void`

###

`createAnswer (successCallback:SessionDescription ‑> Void, failureCallback:DOMError ‑> Void):Promise<Void>`

`createAnswer (?options:AnswerOptions):Promise<SessionDescription>`

###

`createDataChannel (label:String, ?dataChannelDict:DataChannelInit):Dynamic`

###

`createOffer (successCallback:SessionDescription ‑> Void, failureCallback:DOMError ‑> Void, ?options:OfferOptions):Promise<Void>`

`createOffer (?options:OfferOptions):Promise<SessionDescription>`

###

`getConfiguration ():Configuration`

###

`getIdentityAssertion ():Promise<String>`

###

`getLocalStreams ():Array<MediaStream>`

###

`getReceivers ():Array<RtpReceiver>`

###

`getRemoteStreams ():Array<MediaStream>`

###

`getSenders ():Array<RtpSender>`

###

`getStats (selector:MediaStreamTrack, successCallback:StatsReport ‑> Void, failureCallback:DOMError ‑> Void):Promise<Void>`

`getStats (?selector:MediaStreamTrack):Promise<StatsReport>`

###

`getStreamById (streamId:String):MediaStream`

###

`removeStream (stream:MediaStream):Void`

###

`removeTrack (sender:RtpSender):Void`

###

`setIdentityProvider (provider:String, ?protocol:String, ?username:String):Void`

###

`setLocalDescription (description:SessionDescription, successCallback:Void ‑> Void, failureCallback:DOMError ‑> Void):Promise<Void>`

`setLocalDescription (description:SessionDescription):Promise<Void>`

###

`setRemoteDescription (description:SessionDescription, successCallback:Void ‑> Void, failureCallback:DOMError ‑> Void):Promise<Void>`

`setRemoteDescription (description:SessionDescription):Promise<Void>`

### Static methods

###

`staticgenerateCertificate (keygenAlgorithm:EitherType<Dynamic, String>):Promise<Certificate>`

Throws:

`null` | DOMError

### Inherited Variables

### Inherited Methods

#### Defined by EventTarget

###

`addEventListener (type:String, listener:Function, capture:Bool = false):Void`

`addEventListener (type:String, listener:EventListener, capture:Bool = false, ?wantsUntrusted:Bool):Void`

Throws:

`null` | DOMError

###

`dispatchEvent (event:Event):Bool`

Throws:

`null` | DOMError

###

`removeEventListener (type:String, listener:Function, capture:Bool = false):Void`

`removeEventListener (type:String, listener:EventListener, capture:Bool = false):Void`

Throws:

`null` | DOMError