Add ICE candidate event handlers

Add OnICECandidate and OnICEGatheringStateChange methods to
PeerConnection. The main goal of this change is to improve API
compatibility with the JavaScript/Wasm bindings. It does not actually
add trickle ICE support or change the ICE candidate gathering process,
which is still synchronous in the Go implementation. Rather, it fires
the appropriate events similar to they way they would be fired in a true
trickle ICE process.

Remove unused OnNegotiationNeeded event handler. This handler is not
required for most applications and would be difficult to implement in
Go. This commit removes the handler from the JavaScript/Wasm bindings,
which leads to a more similar API for Go and JavaScript/Wasm.

Add OnICEGatheringStateChange to the JavaScript/Wasm bindings. Also
changes the Go implementation so that the function signatures match.
This commit is contained in:
Alex Browne
2019-03-22 15:04:15 -07:00
parent fdcb1a3941
commit 5ee8b1a5c5
9 changed files with 196 additions and 120 deletions

View File

@@ -92,6 +92,20 @@ func valueToUint8OrZero(val js.Value) uint8 {
return uint8(val.Int())
}
func valueToUint16OrZero(val js.Value) uint16 {
if val == js.Null() || val == js.Undefined() {
return 0
}
return uint16(val.Int())
}
func valueToUint32OrZero(val js.Value) uint32 {
if val == js.Null() || val == js.Undefined() {
return 0
}
return uint32(val.Int())
}
func valueToStrings(val js.Value) []string {
result := make([]string, val.Length())
for i := 0; i < val.Length(); i++ {