WebRTC Turn/Stun config
This commit is contained in:
parent
2f572972d8
commit
07b871e374
|
@ -26,17 +26,14 @@ export default class WebRTC
|
||||||
public events : { [eventname:string]: Function[] } = {};
|
public events : { [eventname:string]: Function[] } = {};
|
||||||
public channel : RTCDataChannel | undefined;
|
public channel : RTCDataChannel | undefined;
|
||||||
|
|
||||||
public peer? : Peer;
|
public static defaultRTCConfig : RTCConfiguration = {
|
||||||
|
|
||||||
public FileTransportChannel? : P2PFileSender;
|
|
||||||
|
|
||||||
constructor()
|
|
||||||
{
|
|
||||||
this.rtc = new RTCPeerConnection({
|
|
||||||
iceCandidatePoolSize: 0,
|
iceCandidatePoolSize: 0,
|
||||||
iceTransportPolicy:"all",
|
iceTransportPolicy:"all",
|
||||||
rtcpMuxPolicy:"require",
|
rtcpMuxPolicy:"require",
|
||||||
iceServers:[{
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public static defaultICEServers : RTCIceServer[] = [{
|
||||||
urls: "stun:stun.l.google.com:19302"
|
urls: "stun:stun.l.google.com:19302"
|
||||||
},{
|
},{
|
||||||
urls: "stun:stun1.l.google.com:19302"
|
urls: "stun:stun1.l.google.com:19302"
|
||||||
|
@ -46,8 +43,36 @@ export default class WebRTC
|
||||||
urls: "stun:stun3.l.google.com:19302"
|
urls: "stun:stun3.l.google.com:19302"
|
||||||
},{
|
},{
|
||||||
urls: "stun:stun4.l.google.com:19302"
|
urls: "stun:stun4.l.google.com:19302"
|
||||||
}]
|
}];
|
||||||
});
|
|
||||||
|
public peer? : Peer;
|
||||||
|
|
||||||
|
public FileTransportChannel? : P2PFileSender;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
rtcConfig?: RTCConfiguration,
|
||||||
|
rtcServers?: RTCIceServer[]
|
||||||
|
)
|
||||||
|
{
|
||||||
|
let config : any = {};
|
||||||
|
|
||||||
|
if(rtcConfig)
|
||||||
|
{
|
||||||
|
Object.assign(
|
||||||
|
config,
|
||||||
|
WebRTC.defaultRTCConfig,
|
||||||
|
rtcConfig
|
||||||
|
)
|
||||||
|
}else{
|
||||||
|
Object.assign(
|
||||||
|
config,
|
||||||
|
WebRTC.defaultRTCConfig
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
config.iceServers = rtcServers || WebRTC.defaultICEServers;
|
||||||
|
|
||||||
|
this.rtc = new RTCPeerConnection(config as RTCConfiguration);
|
||||||
this.rtc.addEventListener("connectionstatechange",()=>{
|
this.rtc.addEventListener("connectionstatechange",()=>{
|
||||||
this.eventConnectionState();
|
this.eventConnectionState();
|
||||||
})
|
})
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue