     
     func sendMessage(message: NSString) {
         let messageData = message.dataUsingEncoding(NSISO2022JPStringEncoding, allowLossyConversion: true)
-        sockHandle?.writeData(messageData!)
+        outputStream?.write(UnsafePointer<UInt8>(messageData!.bytes), maxLength: messageData!.length)
     }
     
     func sendLine(message: NSString) {

        isLoggedIn = false
    }

    func connect(serverName: NSString, port: Int) {
        if isConnected {
            disconnect()
        }
        
        //var hostName = CFHOst
    }

    func disconnect() {
        if isLoggedIn {
            let quitString = "/q\n"
            let quitData = quitString.dataUsingEncoding(NSISO2022JPStringEncoding)
            sockHandle?.writeData(quitData!)
            isLoggedIn = false
        }
        
        NSNotificationCenter.defaultCenter().removeObserver(self)
        sockHandle?.closeFile()
        isConnected = false
    }
    

import Foundation

class Italk {
    var inputStream: NSInputStream?
    var outputStream: NSOutputStream?
    var remainData: NSData?
    var isConnected: Bool
    var isLoggedIn: Bool
