Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78aba627a2 | ||
|
|
9044de53d9 | ||
|
|
61ad14f23b |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Socket.IO-Client-Swift"
|
||||
s.version = "1.3.3"
|
||||
s.version = "1.3.4"
|
||||
s.summary = "Socket.IO-client for Swift"
|
||||
s.description = <<-DESC
|
||||
Socket.IO-client for Swift.
|
||||
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
|
||||
s.author = { "Erik" => "nuclear.ace@gmail.com" }
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.10'
|
||||
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.3.3' }
|
||||
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.3.4' }
|
||||
s.source_files = "SwiftIO/**/*.swift"
|
||||
s.requires_arc = true
|
||||
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
|
||||
|
||||
@@ -335,6 +335,13 @@ public class SocketIOClient: NSObject, SocketEngineClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Removes handler(s)
|
||||
*/
|
||||
public func off(event:String) {
|
||||
self.handlers = self.handlers.filter {$0.event == event ? false : true}
|
||||
}
|
||||
|
||||
/**
|
||||
Adds a handler for an event.
|
||||
*/
|
||||
|
||||
+31
-54
@@ -188,55 +188,8 @@ class SocketPacket {
|
||||
return message + "]"
|
||||
}
|
||||
|
||||
private func fillInArray(arr:NSArray) -> NSArray {
|
||||
var newArr = [AnyObject](count: arr.count, repeatedValue: 0)
|
||||
// println(arr)
|
||||
|
||||
for i in 0..<arr.count {
|
||||
if let nest = arr[i] as? NSArray {
|
||||
newArr[i] = self.fillInArray(nest)
|
||||
} else if let dict = arr[i] as? NSDictionary {
|
||||
newArr[i] = self.fillInDict(dict)
|
||||
} else if let str = arr[i] as? String {
|
||||
if let num = str["~~(\\d)"].groups() {
|
||||
newArr[i] = self.binary[num[1].toInt()!]
|
||||
} else {
|
||||
newArr[i] = arr[i]
|
||||
}
|
||||
} else {
|
||||
newArr[i] = arr[i]
|
||||
}
|
||||
}
|
||||
|
||||
return newArr
|
||||
}
|
||||
|
||||
private func fillInDict(dict:NSDictionary) -> NSDictionary {
|
||||
var newDict = [String: AnyObject]()
|
||||
|
||||
for (key, value) in dict {
|
||||
newDict[key as String] = value
|
||||
|
||||
// If the value is a string we need to check
|
||||
// if it is a placeholder for data
|
||||
if let str = value as? String {
|
||||
if let num = str["~~(\\d)"].groups() {
|
||||
newDict[key as String] = self.binary[num[1].toInt()!]
|
||||
} else {
|
||||
newDict[key as String] = str
|
||||
}
|
||||
} else if let nestDict = value as? NSDictionary {
|
||||
newDict[key as String] = self.fillInDict(nestDict)
|
||||
} else if let arr = value as? NSArray {
|
||||
newDict[key as String] = self.fillInArray(arr)
|
||||
}
|
||||
}
|
||||
|
||||
return newDict
|
||||
}
|
||||
|
||||
func fillInPlaceholders() {
|
||||
var newArr = [AnyObject](count: self.data!.count, repeatedValue: 0)
|
||||
var newArr = NSMutableArray(array: self.data!)
|
||||
|
||||
for i in 0..<self.data!.count {
|
||||
if let str = self.data?[i] as? String {
|
||||
@@ -245,15 +198,39 @@ class SocketPacket {
|
||||
} else {
|
||||
newArr[i] = str
|
||||
}
|
||||
} else if let arr = self.data?[i] as? NSArray {
|
||||
newArr[i] = self.fillInArray(arr)
|
||||
} else if let dict = self.data?[i] as? NSDictionary {
|
||||
newArr[i] = self.fillInDict(dict)
|
||||
} else {
|
||||
newArr[i] = self.data![i]
|
||||
} else if self.data?[i] is NSDictionary || self.data?[i] is NSArray {
|
||||
newArr[i] = self._fillInPlaceholders(self.data![i])
|
||||
}
|
||||
}
|
||||
|
||||
self.data = newArr
|
||||
}
|
||||
|
||||
private func _fillInPlaceholders(data:AnyObject) -> AnyObject {
|
||||
if let str = data as? String {
|
||||
if let num = str["~~(\\d)"].groups() {
|
||||
return self.binary[num[1].toInt()!]
|
||||
} else {
|
||||
return str
|
||||
}
|
||||
} else if let dict = data as? NSDictionary {
|
||||
var newDict = NSMutableDictionary(dictionary: dict)
|
||||
|
||||
for (key, value) in dict {
|
||||
newDict[key as NSCopying] = _fillInPlaceholders(value)
|
||||
}
|
||||
|
||||
return newDict
|
||||
} else if let arr = data as? NSArray {
|
||||
var newArr = NSMutableArray(array: arr)
|
||||
|
||||
for i in 0..<arr.count {
|
||||
newArr[i] = _fillInPlaceholders(arr[i])
|
||||
}
|
||||
|
||||
return newArr
|
||||
} else {
|
||||
return data
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user