//建立Timer
let timer = NSTimer(timeInterval: self.responseTimeoutInterval, target: self, selector: Selector("responseTimeout:"), userInfo: Int(packet.header.transactionId), repeats: false)
NSRunLoop.mainRunLoop().addTimer(timer, forMode: NSRunLoopCommonModes)
//接收事件的function
dynamic func responseTimeout(timer: NSTimer) {
logDebug(TAG, "responseTimeout")
if let transactionId = timer.userInfo as? Int {
self.resetResponseTimer(transactionId)
}
self.delegate?.onError(NSError(domain: fusionErrorDomain, code: Int(FusionErrorCode.ResponseTimeout.rawValue), userInfo: nil))
self.socket?.disconnect()
}
沒有留言:
張貼留言