             return
         }
         
-        let type = strMessage["(\\d)"].matches()[0]
+        let type = strMessage["^(\\d)"].groups()?[1]
         
         if type != PacketType.MESSAGE.rawValue {
             // TODO Handle other packets
-            return
-        }
-        
+            println(message)
+            return
+        }
+        
+        // Remove message type
         message.removeAtIndex(message.startIndex)
         self.client.parseSocketMessage(message)
     }

                        return
                    } else if err != nil {
                        println(err)
                        self?.pingTimer?.invalidate()
                        if !self!.client.reconnecting {
                            self?.client.tryReconnect(triesLeft: self!.client.reconnectAttempts)
                        }
                        return
                    }
                    

        }
    }
    
    // A poll failed, try and reconnect
    private func handlePollingFailed() {
        if !self.client.reconnecting {
            self.pingTimer?.invalidate()
            self.client.tryReconnect(triesLeft: self.client.reconnectAttempts)
        }
    }
    
    // Translatation of engine.io-parser#decodePayload
    func parsePollingMessage(str:String) {
        if str.length == 1 {
            return
        }
        
        // println(str)
        
        var length = ""
        var n = 0
        var msg = ""
        
        func testLength(length:String, inout n:Int) -> Bool {
            if let num = length.toInt() {
                n = num
                if num != n {
                    return true
                }
            }
            
            return false
        }
        
        for var i = 0, l = str.length; i < l; i++ {
            let strArray = Array(str)
            let chr = String(strArray[i])
            
            if chr != ":" {
                length += chr
            } else {
                if  testLength(length, &n) || length == "" {
                    println("parsing error at testlength")
                    return
                }
                
                msg = String(strArray[i+1...i+n])
                
                if let lengthInt = length.toInt() {
                    if lengthInt != msg.length {
                        println("parsing error")
                        return
                    }
                }
                
                if msg.length != 0 {
                    self.parseEngineMessage(msg)
                }
                
                i += n
                length = ""
            }
        }
    }
    
    func parseEngineMessage(message:AnyObject?) {
        // println(message)
        
        if let data = message as? NSData {
            // Strip off message type
            self.client.parseSocketMessage(data.subdataWithRange(NSMakeRange(1, data.length - 1)))
