 import Foundation
 import Starscream
 
+/**
+ Abstracts a WebSockets connection. In particular, `WatsonWebSocket` internally manages the state
+ of the connection and queues any operations requested while the socket is disconnected.
+ */
 class WatsonWebSocket {
 
     private let authStrategy: AuthenticationStrategy

    private var retries = 0
    private var maxRetries = 2

    var onText: (String -> Void)?
    var onData: (NSData -> Void)?
    var onError: (NSError -> Void)?

    init(authStrategy: AuthenticationStrategy, url: NSURL, protocols: [String]? = nil) {
        self.authStrategy = authStrategy


            self.operations.suspended = true
            self.isConnecting = false
            if self.isAuthenticationFailure(error) {
                self.connectWithToken()
            } else if let error = error {
                self.isClosedByError = true
