File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -308,13 +308,14 @@ public class WebSocket : NSObject, NSStreamDelegate {
308
308
309
309
let bytes = UnsafePointer < UInt8 > ( data. bytes)
310
310
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 }
312
313
while !outStream. hasSpaceAvailable {
313
314
usleep ( 100 ) //wait until the socket is ready
314
315
timeout -= 100
315
316
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 ) )
318
319
return
319
320
} else if outStream. streamError != nil {
320
321
return //disconnectStream will be called.
You can’t perform that action at this time.
0 commit comments