Skip to content

Commit e107d9b

Browse files
fb55freak4pc
authored andcommitted
Use WebsocketClient protocol to support mocking (#23)
1 parent e249c0b commit e107d9b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Source/RxStarscream.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ public enum WebSocketEvent {
1515
case pong
1616
}
1717

18-
public class RxWebSocketDelegateProxy: DelegateProxy<WebSocket, NSObjectProtocol>, DelegateProxyType, WebSocketDelegate, WebSocketPongDelegate {
18+
public class RxWebSocketDelegateProxy<Client: WebSocketClient>: DelegateProxy<Client, NSObjectProtocol>, DelegateProxyType, WebSocketDelegate, WebSocketPongDelegate {
1919

2020
private weak var forwardDelegate: WebSocketDelegate?
2121
private weak var forwardPongDelegate: WebSocketPongDelegate?
2222

2323
fileprivate let subject = PublishSubject<WebSocketEvent>()
2424

25-
required public init(websocket: WebSocket) {
25+
required public init(websocket: Client) {
2626
super.init(parentObject: websocket, delegateProxy: RxWebSocketDelegateProxy.self)
2727
}
2828

29-
public static func currentDelegate(for object: WebSocket) -> NSObjectProtocol? {
29+
public static func currentDelegate(for object: Client) -> NSObjectProtocol? {
3030
return object.delegate as? NSObjectProtocol
3131
}
3232

33-
public static func setCurrentDelegate(_ delegate: NSObjectProtocol?, to object: WebSocket) {
33+
public static func setCurrentDelegate(_ delegate: NSObjectProtocol?, to object: Client) {
3434
object.delegate = delegate as? WebSocketDelegate
3535
object.pongDelegate = delegate as? WebSocketPongDelegate
3636
}
@@ -69,7 +69,7 @@ public class RxWebSocketDelegateProxy: DelegateProxy<WebSocket, NSObjectProtocol
6969
}
7070
}
7171

72-
extension Reactive where Base: WebSocket {
72+
extension Reactive where Base: WebSocketClient {
7373

7474
public var response: Observable<WebSocketEvent> {
7575
return RxWebSocketDelegateProxy.proxy(for: base).subject

0 commit comments

Comments
 (0)