import Foundation
import NIO
import NIOHTTP1

/// Handles messages received by a connected WebSocket server.
public protocol WebSocketClientDelegate : AnyObject {
    func onOpen(channel: Channel)
    func onMessage(text: String) throws 
    func onMessage(data: Data) throws
    func onClose(channel: Channel, data: Data)
    func onError(error: Swift.Error?, status: HTTPResponseStatus?) throws
}

// Add empty default implementations
extension WebSocketClientDelegate {
    public func onOpen(channel: Channel) {
    }
    public func onMessage(text: String) {
    }
    public func onMessage(data: Data) {
    }
    public func onClose(channel: Channel, data: Data) {
    }
    public func onError(error: Swift.Error?, status: HTTPResponseStatus?) throws {
    }
}
