     
     public enum Error: ErrorType { case UnknownOpCode(String), UnMaskedFrame, ProtocolError(String) }
     public enum OpCode: UInt8 { case Continue = 0x00, Close = 0x08, Ping = 0x09, Pong = 0x0A, Text = 0x01, Binary = 0x02 }
+    public enum Control: ErrorType { case Close }
     
     public class Frame {
         public var opcode = OpCode.Close

        }
        let protocolSessionClosure: (Socket -> Void) = { socket in
            let session = WebSocketSession(socket)
            do {
                while true {
                    let frame = try session.readFrame()
                    switch frame.opcode {
                    case .Text:
                        if let handleText = text {
                            handleText(session, String.fromUInt8(frame.payload))
                        }
                    case .Binary:
                        if let handleBinary = binary {
                            handleBinary(session, frame.payload)
                        }
                    case .Close:
                        session.writeCloseFrame()
                    case .Continue:
                        break
                    case .Ping:
                        if frame.payload.count > 125 {
                            throw WebSocketSession.Error.ProtocolError("payload gretter than 125 octets.")
                        } else {
                            session.writeFrame(ArraySlice(frame.payload), .Pong)
                        }
                        break
                    case .Pong:
                        break
                    }
                }
            } catch let error {
                switch error {
                case WebSocketSession.Error.UnknownOpCode:
                    print("Unknown Op Code: \(error)")
                default:

    
    deinit {
        writeCloseFrame()
        socket.shutdwn()
    }
    
    public func writeText(text: String) -> Void {
