     
 }
 
-open class MediaChannel: AliveMonitorable {
+// MARK: -
+
+open class MediaChannel {
     
     public enum State {
         case connecting

        case waitingPeer
    }
    
    public var handlers: MediaChannelHandlers = MediaChannelHandlers()

    public var configuration: Configuration
    public var clientId: String?
    public var peerChannel: PeerChannel
    
    public var streams: [MediaStream] {
        get { return peerChannel.streams }
    }
    
    public var mainStream: MediaStream? {
        get { return streams.first }
    }
    
    public var state: State = .disconnected {
        didSet {
            Log.trace(type: .mediaChannel,
                      message: "changed state from \(oldValue) to \(state)")
        }
    }

    public var aliveState: AliveState {
        get {
            switch state {
            case .connected:
                return .available
            case .disconnecting, .disconnected:
                return .unavailable
            default:
                return .connecting
            }
        }
    }
    
    private var aliveMonitor: AliveMonitor = AliveMonitor()
    private var connectionTimer: ConnectionTimer?
    private var onConnectHandler: Callback1<Error?, Void> = Callback1(repeats: false)
    

            onConnectHandler.execute(error)
        }
    }
    
}

// MARK: - AliveMonitorable

extension MediaChannel: AliveMonitorable {
    
    public var aliveState: AliveState {
        switch state {
        case .connected:
            return .available
        case .disconnecting, .disconnected:
            return .unavailable
        default:
            return .connecting
        }
    }
    
}
