Ejemplo n.º 1
0
        private void DisposeConnection()
        {
            try
            {
                Logger.LogInformation("Disposing connection...");

                if (_dataChannel != null)
                {
                    _dataChannel.onopen  -= OnDataChannelOpened;
                    _dataChannel.onclose -= OnDataChannelClosed;
                    _dataChannel.close();
                }

                if (_connection != null)
                {
                    _connection.ondatachannel           += OnDataChannelInitialized;
                    _connection.onicecandidate          += OnIceCandidateAvailable;
                    _connection.onconnectionstatechange += OnConnectionStateChanged;
                    _connection.close();
                    _connection.Dispose();
                    _connection = null;
                }
            }
            catch (Exception ex)
            {
                Logger.LogWarning(ex, "Error occurred while trying to dispose the connection.");
            }
        }