import Foundation
import TigaseSwift

class DiscoEventHandler: XmppServiceEventHandler {
    public static let ACCOUNT_FEATURES_RECEIVED = Notification.Name("accountFeaturesReceived")
    public static let SERVER_FEATURES_RECEIVED = Notification.Name("serverFeaturesReceived")

    let events: [Event] = [DiscoveryModule.AccountFeaturesReceivedEvent.TYPE, DiscoveryModule.ServerFeaturesReceivedEvent.TYPE]

    func handle(event: Event) {
        switch event {
        case let e as DiscoveryModule.AccountFeaturesReceivedEvent:
            NotificationCenter.default.post(name: DiscoEventHandler.ACCOUNT_FEATURES_RECEIVED, object: e)

        case let e as DiscoveryModule.ServerFeaturesReceivedEvent:
            NotificationCenter.default.post(name: DiscoEventHandler.SERVER_FEATURES_RECEIVED, object: e)

        default:
            break
        }
    }
}
