Skip to content

Commit 2a25027

Browse files
committed
change to weak self
1 parent 15dfba4 commit 2a25027

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Source/WebSocket.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,14 @@ public class WebSocket : NSObject, NSStreamDelegate {
308308

309309
let bytes = UnsafePointer<UInt8>(data.bytes)
310310
var timeout = 5000000 //wait 5 seconds before giving up
311-
writeQueue.addOperationWithBlock { [unowned self] in
311+
writeQueue.addOperationWithBlock { [weak self] in
312+
guard let this = self else { return }
312313
while !outStream.hasSpaceAvailable {
313314
usleep(100) //wait until the socket is ready
314315
timeout -= 100
315316
if timeout < 0 {
316-
self.cleanupStream()
317-
self.doDisconnect(self.errorWithDetail("write wait timed out", code: 2))
317+
this.cleanupStream()
318+
this.doDisconnect(this.errorWithDetail("write wait timed out", code: 2))
318319
return
319320
} else if outStream.streamError != nil {
320321
return //disconnectStream will be called.

0 commit comments

Comments
 (0)