Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Fix readyState in the deferred open case. Fixes #91. #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Source/WebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ private class InnerWebSocket: Hashable {
var _event = WebSocketEvents()
var _eventDelegate: WebSocketDelegate?
var _binaryType = WebSocketBinaryType.uInt8Array
var _readyState = WebSocketReadyState.connecting
var _readyState = WebSocketReadyState.closed
var _networkTimeout = TimeInterval(-1)


Expand Down Expand Up @@ -1672,6 +1672,9 @@ open class WebSocket: NSObject {
let hasURL = request.url != nil
opened = hasURL
ws = InnerWebSocket(request: request, subProtocols: subProtocols, stub: !hasURL)
if opened {
ws.privateReadyState = .connecting
}
super.init()
// weak/strong pattern from:
// http://stackoverflow.com/a/17105368/424124
Expand Down Expand Up @@ -1749,6 +1752,7 @@ open class WebSocket: NSObject {
}
opened = true
ws = ws.copyOpen(request, subProtocols: subProtocols)
ws.privateReadyState = .connecting
}
/// Opens a closed WebSocket connection from an NSURLRequest; Uses the same request and protocols as previously closed WebSocket
open func open(){
Expand Down