 	var onCreateDescriptionFailureCallback: ((error: NSError) -> Void)!
 	var onSetDescriptionSuccessCallback: (() -> Void)!
 	var onSetDescriptionFailureCallback: ((error: NSError) -> Void)!
-
+    var onGetStatsCallback: ((array: NSArray) -> Void)!
 
 	init(
 		rtcPeerConnectionFactory: RTCPeerConnectionFactory,

import Foundation


class PluginRTCPeerConnection : NSObject, RTCPeerConnectionDelegate, RTCSessionDescriptionDelegate {
	var rtcPeerConnectionFactory: RTCPeerConnectionFactory
	var rtcPeerConnection: RTCPeerConnection!
	var pluginRTCPeerConnectionConfig: PluginRTCPeerConnectionConfig

			self.onSetDescriptionFailureCallback(error: error)
		}
	}

    /**
     * Methods inherited from RTCStatsDelegate
     */

    func peerConnection(peerConnection: RTCPeerConnection!,
        didGetStats stats: [AnyObject]!) {

            var jsStats = [NSDictionary]()

            for stat in stats as NSArray {
                var jsValues = Dictionary<String,String>()

                for pair in stat.values as! [RTCPair] {
                    jsValues[pair.key] = pair.value;
                }

                jsStats.append(["reportId": stat.reportId, "type": stat.type, "timestamp": stat.timestamp, "values": jsValues]);

            }

        self.onGetStatsCallback(array: jsStats);
    }
}
