public static Enums.IceConnectionState ToNativePort(this IceConnectionState platformNative) { if (platformNative == IceConnectionState.Checking) { return(Enums.IceConnectionState.Checking); } if (platformNative == IceConnectionState.Closed) { return(Enums.IceConnectionState.Closed); } if (platformNative == IceConnectionState.Completed) { return(Enums.IceConnectionState.Completed); } if (platformNative == IceConnectionState.Connected) { return(Enums.IceConnectionState.Connected); } if (platformNative == IceConnectionState.Disconnected) { return(Enums.IceConnectionState.Disconnected); } if (platformNative == IceConnectionState.Failed) { return(Enums.IceConnectionState.Failed); } if (platformNative == IceConnectionState.New) { return(Enums.IceConnectionState.New); } throw new ArgumentOutOfRangeException(nameof(platformNative), platformNative, null); }
public void OnIceConnectionChange(Webrtc.PeerConnection.IceConnectionState p0) { OnIceConnectionStateChange?.Invoke(this, EventArgs.Empty); // !!! I don't know why Android DOES NOT provide Connection State Change event??? // I drive this event from Ice Connection State Change event here for now. #if false if (p0 == Webrtc.PeerConnection.IceConnectionState.New) { } else if (p0 == Webrtc.PeerConnection.IceConnectionState.Checking) { } else if (p0 == Webrtc.PeerConnection.IceConnectionState.Connected) { Timer timer = null; int count = 5; // Make sure that state is connected with several attempts. timer = new Timer(new TimerCallback((state) => { if (((Webrtc.PeerConnection)NativeObject).ConnectionState() == Webrtc.PeerConnection.PeerConnectionState.Connected || --count == 0) { timer.Dispose(); System.Diagnostics.Debug.WriteLine($"OOOOOOOOOOOOOOOOOOOOOOO PeerConnection GENERATED CONNECTED {count}"); OnConnectionStateChanged?.Invoke(this, EventArgs.Empty); return; } }), null, 10, 50); return; } else if (p0 == Webrtc.PeerConnection.IceConnectionState.Completed) { } else if (p0 == Webrtc.PeerConnection.IceConnectionState.Failed) { } else if (p0 == Webrtc.PeerConnection.IceConnectionState.Disconnected) { Timer timer = null; int count = 5; // Make sure that state is disconnected with several attempsts. timer = new Timer(new TimerCallback((state) => { if (((Webrtc.PeerConnection)NativeObject).ConnectionState() == Webrtc.PeerConnection.PeerConnectionState.Disconnected || --count == 0) { timer.Dispose(); OnConnectionStateChanged?.Invoke(this, EventArgs.Empty); return; } }), null, 10, 50); return; } else if (p0 == Webrtc.PeerConnection.IceConnectionState.Closed) { } #endif if (p0 == PeerConnection.IceConnectionState.Connected || p0 == PeerConnection.IceConnectionState.Completed) { if (!_isConnected) { _isConnected = true; OnConnectionStateChanged?.Invoke(this, EventArgs.Empty); } } else if (_isConnected) { _isConnected = false; OnConnectionStateChanged?.Invoke(this, EventArgs.Empty); } }