         }
     }
     
+    func createBinaryMessage() -> String {
+        var array = "45\(self.placeholders)-["
+        array += "\"" + event + "\""
+        if (args? != nil) {
+            if (args is NSDictionary) {
+                array += ","
+                var jsonSendError:NSError?
+                var jsonSend = NSJSONSerialization.dataWithJSONObject(args as NSDictionary,
+                    options: NSJSONWritingOptions(0), error: &jsonSendError)
+                var jsonString = NSString(data: jsonSend!, encoding: NSUTF8StringEncoding)
+                return array + jsonString! + "]"
+            } else {
+                array += ",\"\(args!)\""
+                return array + "]"
+            }
+        } else {
+            return array + "]"
+        }
+    }
+    
     mutating func fillInPlaceHolder(data:NSData) -> Bool {
         func checkDoEvent() -> Bool {
             if (self.placeholders == self.currentPlace) {

        }
    }
    
    // Sends binary data
    func sendBinaryData(event:String, data:NSData) {
        println("should send binary")
        let message = binaryMessage(event: event, data: data)
        //        var hexBits = ""
        //        var byteArray = [UInt8](count: data.length, repeatedValue: 0x0)
        //        data.getBytes(&byteArray, length:data.length)
        //        for value in byteArray {
        //            hexBits += NSString(format:"%2X", value) as String
        //        }
        //        let hexBytes = hexBits.stringByReplacingOccurrencesOfString("\u{0020}", withString: "0",
        //            options: NSStringCompareOptions.CaseInsensitiveSearch)
        //        println(hexBytes)
        // println("binary message " + message.createMessage())
        // println(byteArray)
        // println("[" + ", ".join(byteArray.map({"\($0)"})) + "]")
        self.io?.send(message.createMessage())
        self.io?.send(data)
    }
    
    // Sends ping
    func sendPing() {
        if (!self.connected) {

                let event = binaryGroup[2]
                let mutMessageObject = RegexMutable(binaryGroup[3])
                let placeholdersRemoved = mutMessageObject["(\\{\"_placeholder\":true,\"num\":(\\d*)\\})"] ~= "~~$2"
                let mes = Event(event: event, args: placeholdersRemoved,
                    placeholders: numberOfPlaceholders.integerValue)
                self.lastSocketMessage = mes
                return
