diff --git a/SwiftIO/SocketEngine.swift b/SwiftIO/SocketEngine.swift index 8ec9ef2f..33af2fb3 100644 --- a/SwiftIO/SocketEngine.swift +++ b/SwiftIO/SocketEngine.swift @@ -179,7 +179,7 @@ public class SocketEngine: NSObject, WebSocketDelegate { // println(data) - if var str = NSString(data: data, encoding: NSUTF8StringEncoding) as? String { + if let str = NSString(data: data, encoding: NSUTF8StringEncoding) as? String { dispatch_async(self!.parseQueue) {callback(str)} } diff --git a/SwiftIO/SocketParser.swift b/SwiftIO/SocketParser.swift index 921905fa..9791a5b0 100644 --- a/SwiftIO/SocketParser.swift +++ b/SwiftIO/SocketParser.swift @@ -217,20 +217,16 @@ class SocketParser { return } - /** Begin check for message **/ - let messageGroups = stringMessage["(\\d*)\\/?(\\w*)?,?(\\d*)?\\[\"(.*?)\",?(.*?)?\\]$"].groups() + let messageGroups = stringMessage["(\\d*)\\/?(\\w*)?,?(\\d*)?\\[\"(.*?)\",?(.*?)?\\]$", + NSRegularExpressionOptions.DotMatchesLineSeparators].groups() if messageGroups == nil { NSLog("Error in groups") return } - // let messageGroups = SwiftRegex(target: stringMessage as NSString, - // pattern: "(\\d*)\\/?(\\w*)?,?(\\d*)?\\[\"(.*?)\",?(.*?)?\\]$", - // options: NSRegularExpressionOptions.DotMatchesLineSeparators).groups() - if messageGroups![1].hasPrefix("2") { var mesNum = messageGroups![1] var ackNum:String @@ -343,10 +339,8 @@ class SocketParser { /** Begin check for binary placeholders **/ - let binaryGroup = message["^(\\d*)-\\/?(\\w*)?,?(\\d*)?\\[(\".*?\")?,?(.*)?\\]$"].groups() - // let binaryGroup = SwiftRegex(target: message, - // pattern: "^(\\d*)-\\/?(\\w*)?,?(\\d*)?\\[(\".*?\")?,?(.*)?\\]$", - // options: NSRegularExpressionOptions.DotMatchesLineSeparators).groups() + let binaryGroup = message["^(\\d*)-\\/?(\\w*)?,?(\\d*)?\\[(\".*?\")?,?(.*)?\\]$", + NSRegularExpressionOptions.DotMatchesLineSeparators].groups() if binaryGroup == nil { return @@ -359,6 +353,7 @@ class SocketParser { var mutMessageObject:String var namespace:String? var numberOfPlaceholders:String + let messageType = binaryGroup![1] namespace = binaryGroup![2] @@ -422,4 +417,4 @@ class SocketParser { End check for binary placeholders **/ } -} \ No newline at end of file +}