string ipv4, ipv6, ipNat;
// disable WebRTC
instance.WebRTCWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.WebRTCMode.Disable;
// then WebRTC is disabled, the output variables will be empty
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (!string.IsNullOrWhiteSpace(ipv4) || !string.IsNullOrWhiteSpace(ipv6) || !string.IsNullOrWhiteSpace(ipNat))
throw new Exception("Adresses should be empty then webRTC disabled!!!");
// enable WebRTC
instance.WebRTCWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.WebRTCMode.Enable;
// then WebRTC is enabled, the output variables will be "default"
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (!ipv4.Equals("default") || !ipv6.Equals("default") || !ipNat.Equals("default"))
throw new Exception("Adresses should be 'default' then webRTC enabled!!!");
// emulate WebRTC
instance.WebRTCWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.WebRTCMode.Emulate;
// now the output variables will be empty, because we didn't set any values
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (!string.IsNullOrWhiteSpace(ipv4) || !string.IsNullOrWhiteSpace(ipv6) || !string.IsNullOrWhiteSpace(ipNat))
throw new Exception("Adresses should be empty then webRTC emulate, but not configured!!!");
// format for IPv4 is "ip:port"
// for IPv6 are "ip" or "[ip]:port"
var ipv4Emulate = "192.168.5.5:5687";
var ipv6Emulate = "[2001:0:53aa:62c:24cb:218c:9257:63c]:33282";
var ipNatEmulate = "54.234.21.12:7654";
// you can emulate only local ipv4
instance.SetWebRTCAdresses(ipv4Emulate);
// now the output variable ipv4 will be "192.168.5.5:5687", other variables will be empty
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (ipv4 != ipv4Emulate || !string.IsNullOrWhiteSpace(ipv6) || !string.IsNullOrWhiteSpace(ipNat))
throw new Exception("Wrong set adresses, set only ipv4!!!");
// or you can emulate only local ipv4 and ipv6
instance.SetWebRTCAdresses(ipv4Emulate, ipv6Emulate);
// now the output variable ipv4 will be "192.168.5.5:5687", ipv6 will be "[2001:0:53aa:62c:24cb:218c:9257:63c]:33282", but ipNat will be empty
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (ipv4 != ipv4Emulate || ipv6 != ipv6Emulate || !string.IsNullOrWhiteSpace(ipNat))
throw new Exception("Wrong set adresses, set ipv4 and ipv6!!!");
// or you can emulate all addresses
instance.SetWebRTCAdresses(ipv4Emulate, ipv6Emulate, ipNatEmulate);
// now the output variable ipv4 will be "192.168.5.5:5687", ipv6 will be "[2001:0:53aa:62c:24cb:218c:9257:63c]:33282", ipNat will be "54.234.21.12:7654"
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (ipv4 != ipv4Emulate || ipv6 != ipv6Emulate || ipNat != ipNatEmulate)
throw new Exception("Wrong set adresses, set ipv4, ipv6, ipNat!!!");