Skip to content

Commit

Permalink
#11
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearace committed Mar 16, 2015
1 parent fea1687 commit 44e2781
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion SwiftIO/SocketEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
}

Expand Down
17 changes: 6 additions & 11 deletions SwiftIO/SocketParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -359,6 +353,7 @@ class SocketParser {
var mutMessageObject:String
var namespace:String?
var numberOfPlaceholders:String

let messageType = binaryGroup![1]

namespace = binaryGroup![2]
Expand Down Expand Up @@ -422,4 +417,4 @@ class SocketParser {
End check for binary placeholders
**/
}
}
}

0 comments on commit 44e2781

Please sign in to comment.