change to weak self
This commit is contained in:
parent
15dfba42a7
commit
2a25027077
@ -308,13 +308,14 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
|||||||
|
|
||||||
let bytes = UnsafePointer<UInt8>(data.bytes)
|
let bytes = UnsafePointer<UInt8>(data.bytes)
|
||||||
var timeout = 5000000 //wait 5 seconds before giving up
|
var timeout = 5000000 //wait 5 seconds before giving up
|
||||||
writeQueue.addOperationWithBlock { [unowned self] in
|
writeQueue.addOperationWithBlock { [weak self] in
|
||||||
|
guard let this = self else { return }
|
||||||
while !outStream.hasSpaceAvailable {
|
while !outStream.hasSpaceAvailable {
|
||||||
usleep(100) //wait until the socket is ready
|
usleep(100) //wait until the socket is ready
|
||||||
timeout -= 100
|
timeout -= 100
|
||||||
if timeout < 0 {
|
if timeout < 0 {
|
||||||
self.cleanupStream()
|
this.cleanupStream()
|
||||||
self.doDisconnect(self.errorWithDetail("write wait timed out", code: 2))
|
this.doDisconnect(this.errorWithDetail("write wait timed out", code: 2))
|
||||||
return
|
return
|
||||||
} else if outStream.streamError != nil {
|
} else if outStream.streamError != nil {
|
||||||
return //disconnectStream will be called.
|
return //disconnectStream will be called.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user