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 {
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.
You can’t perform that action at this time.
0 commit comments