Skip to content

Commit da1cf9e

Browse files
committed
1 parent 57731be commit da1cf9e

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

SwiftIO/SocketAnyEvent.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// SocketAnyEvent.swift
3+
// Socket.IO-Swift
4+
//
5+
// Created by Erik Little on 3/28/15.
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
25+
import Foundation
26+
27+
@objc public class SocketAnyEvent {
28+
public let event:String!
29+
public var items:[AnyObject]?
30+
31+
init(event:String, items:[AnyObject]?) {
32+
self.event = event
33+
self.items = items
34+
}
35+
}

SwiftIO/SocketEventHandler.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import Foundation
2626

2727
public typealias NormalCallback = (NSArray?, AckEmitter?) -> Void
28-
public typealias AnyHandler = (event:String, items:AnyObject?)
2928
public typealias AckEmitter = (AnyObject...) -> Void
3029

3130
private func emitAckCallback(socket:SocketIOClient, num:Int)

SwiftIO/SocketIOClient.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class SocketIOClient: NSObject, SocketEngineClient {
2828
let reconnectAttempts:Int!
2929
private lazy var params = [String: AnyObject]()
3030
private var ackHandlers = ContiguousArray<SocketAckHandler>()
31-
private var anyHandler:((AnyHandler) -> Void)?
31+
private var anyHandler:((SocketAnyEvent) -> Void)?
3232
private var _closed = false
3333
private var _connected = false
3434
private var _connecting = false
@@ -360,7 +360,7 @@ public class SocketIOClient: NSObject, SocketEngineClient {
360360

361361
if self.anyHandler != nil {
362362
dispatch_async(dispatch_get_main_queue()) {[weak self] in
363-
self?.anyHandler?((event, data))
363+
self?.anyHandler?(SocketAnyEvent(event: event, items: data))
364364
return
365365
}
366366
}
@@ -400,7 +400,7 @@ public class SocketIOClient: NSObject, SocketEngineClient {
400400
/**
401401
Adds a handler that will be called on every event.
402402
*/
403-
public func onAny(handler:(AnyHandler) -> Void) {
403+
public func onAny(handler:(SocketAnyEvent) -> Void) {
404404
self.anyHandler = handler
405405
}
406406

0 commit comments

Comments
 (0)