         if totalSize > 0 {
             if validateResponse(buffer, bufferLen: totalSize) {
                 dispatch_async(dispatch_get_main_queue(),{
-                    self.workaroundMethod()
+                    //self.workaroundMethod()
                     if let connectBlock = self._connectedBlock{
                         connectBlock()
                     }
                     else{
-                        self.delegate?.websocketDidConnect!()
+                        self.delegate!.websocketDidConnect()
                     }
                 })
                 totalSize += 1 //skip the last \n

                connected = processHTTP(buffer, bufferLen: length)
                if !connected {
                    dispatch_async(dispatch_get_main_queue(),{
                        self.workaroundMethod()
                        let error = self.errorWithDetail("Invalid HTTP upgrade", code: 1)
                        if let failBlock = self._failureBlock{
                            failBlock(error)
                        }
                        else{
                            self.delegate?.websocketDidDisconnect!(error)
                        }
                    })
                }

import Foundation
import CoreFoundation

public protocol WebSocketDelegate: class {
    func websocketDidConnect()
    func websocketDidDisconnect(error: NSError?)
    func websocketDidWriteError(error: NSError?)
    func websocketDidReceiveMessage(text: String)
    func websocketDidReceiveData(data: NSData)
}

public class WebSocket : NSObject, NSStreamDelegate {
