diff --git a/DXFeedFramework.xcodeproj/project.pbxproj b/DXFeedFramework.xcodeproj/project.pbxproj index 504aae02a..e3dbeb46a 100644 --- a/DXFeedFramework.xcodeproj/project.pbxproj +++ b/DXFeedFramework.xcodeproj/project.pbxproj @@ -56,7 +56,7 @@ 6417DD232A39CAB2008912D6 /* LatencyDiagnostic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6417DD1E2A39C9A7008912D6 /* LatencyDiagnostic.swift */; }; 641A599A2AB4794E003899FB /* TradeETH.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641A59992AB4794E003899FB /* TradeETH.swift */; }; 641AC1A92A61AE4000EF6D6C /* DXAliases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641AC1A82A61AE4000EF6D6C /* DXAliases.swift */; }; - 641BCBBC2A20ED8100FE23C2 /* DXEndpointObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641BCBBB2A20ED8100FE23C2 /* DXEndpointObserver.swift */; }; + 641BCBBC2A20ED8100FE23C2 /* DXEndpointListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641BCBBB2A20ED8100FE23C2 /* DXEndpointListener.swift */; }; 641BCBC12A21077800FE23C2 /* EventCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641BCBC02A21077800FE23C2 /* EventCode.swift */; }; 641BDD582AC71CCE00236B78 /* LatencyTestTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641BDD572AC71CCE00236B78 /* LatencyTestTool.swift */; }; 641BDD592AC7215200236B78 /* LatencyDiagnostic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6417DD1E2A39C9A7008912D6 /* LatencyDiagnostic.swift */; }; @@ -321,7 +321,7 @@ 64DA26B82AA20095005B1757 /* NativeInstrumentProfileConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26B72AA20095005B1757 /* NativeInstrumentProfileConnection.swift */; }; 64DA26BA2AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26B92AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift */; }; 64DA26BC2AA20B66005B1757 /* InstrumentProfileConnectionState+ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26BB2AA20B66005B1757 /* InstrumentProfileConnectionState+ext.swift */; }; - 64DA26BE2AA20EDB005B1757 /* DXInstrumentProfileConnectionObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26BD2AA20EDB005B1757 /* DXInstrumentProfileConnectionObserver.swift */; }; + 64DA26BE2AA20EDB005B1757 /* DXInstrumentProfileConnectionListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26BD2AA20EDB005B1757 /* DXInstrumentProfileConnectionListener.swift */; }; 64DA26C02AA224EB005B1757 /* NativeIPFConnectionListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26BF2AA224EB005B1757 /* NativeIPFConnectionListener.swift */; }; 64DB79342A376E1B00229597 /* DXFeedFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 803BAC0D29BFA50700FFAB1C /* DXFeedFramework.framework */; }; 64DB79352A376E1B00229597 /* DXFeedFramework.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 803BAC0D29BFA50700FFAB1C /* DXFeedFramework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -561,7 +561,7 @@ 641AC1A82A61AE4000EF6D6C /* DXAliases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXAliases.swift; sourceTree = ""; }; 641BCBB32A1F8ABA00FE23C2 /* XCTestCase+Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+Utils.swift"; sourceTree = ""; }; 641BCBB92A1FB42500FE23C2 /* TestListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestListener.swift; sourceTree = ""; }; - 641BCBBB2A20ED8100FE23C2 /* DXEndpointObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXEndpointObserver.swift; sourceTree = ""; }; + 641BCBBB2A20ED8100FE23C2 /* DXEndpointListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXEndpointListener.swift; sourceTree = ""; }; 641BCBC02A21077800FE23C2 /* EventCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventCode.swift; sourceTree = ""; }; 641BDD572AC71CCE00236B78 /* LatencyTestTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LatencyTestTool.swift; sourceTree = ""; }; 641BDD5A2AC72BD400236B78 /* ConcurrentWeakHashTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConcurrentWeakHashTable.swift; sourceTree = ""; }; @@ -787,7 +787,7 @@ 64DA26B72AA20095005B1757 /* NativeInstrumentProfileConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeInstrumentProfileConnection.swift; sourceTree = ""; }; 64DA26B92AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXInstrumentProfileConnectionState.swift; sourceTree = ""; }; 64DA26BB2AA20B66005B1757 /* InstrumentProfileConnectionState+ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InstrumentProfileConnectionState+ext.swift"; sourceTree = ""; }; - 64DA26BD2AA20EDB005B1757 /* DXInstrumentProfileConnectionObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXInstrumentProfileConnectionObserver.swift; sourceTree = ""; }; + 64DA26BD2AA20EDB005B1757 /* DXInstrumentProfileConnectionListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXInstrumentProfileConnectionListener.swift; sourceTree = ""; }; 64DA26BF2AA224EB005B1757 /* NativeIPFConnectionListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeIPFConnectionListener.swift; sourceTree = ""; }; 64E342512AAB29CF00457994 /* InstrumentProfileType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstrumentProfileType.swift; sourceTree = ""; }; 64E3637A2AD83459002E2B0D /* SeriesMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeriesMapper.swift; sourceTree = ""; }; @@ -1384,7 +1384,7 @@ 6464075C2AA1C69E006FF769 /* DXInstrumentProfileUpdateListener.swift */, 64DA26B52AA1EF47005B1757 /* DXProfileIterator.swift */, 64DA26B92AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift */, - 64DA26BD2AA20EDB005B1757 /* DXInstrumentProfileConnectionObserver.swift */, + 64DA26BD2AA20EDB005B1757 /* DXInstrumentProfileConnectionListener.swift */, ); path = Live; sourceTree = ""; @@ -1515,7 +1515,7 @@ 64656F5A2A1B9784006A0B19 /* DXFeed.swift */, 64656F662A1CCFC2006A0B19 /* DXPublisher.swift */, 64656F6C2A1CFB10006A0B19 /* DXEndpointState.swift */, - 641BCBBB2A20ED8100FE23C2 /* DXEndpointObserver.swift */, + 641BCBBB2A20ED8100FE23C2 /* DXEndpointListener.swift */, 64104FC82A26298D00D1FC41 /* DXFeedSubcription.swift */, 64ACBCD82A279F7900032C53 /* DXEventListener.swift */, ); @@ -2201,7 +2201,7 @@ 6498E6BD2AB1E0510093A065 /* ScheduleSession.swift in Sources */, 64BDDB262AD6F6B500694210 /* IcebergType.swift in Sources */, 8088D76529C0FBCE00F240CB /* ThreadManager.swift in Sources */, - 64DA26BE2AA20EDB005B1757 /* DXInstrumentProfileConnectionObserver.swift in Sources */, + 64DA26BE2AA20EDB005B1757 /* DXInstrumentProfileConnectionListener.swift in Sources */, 64656F732A1D0A84006A0B19 /* EndpointListener.swift in Sources */, 64BDDB282AD7D8D300694210 /* Order+Ext.swift in Sources */, 6486B9582AD00BDC00D8D5FA /* Summary.swift in Sources */, @@ -2232,7 +2232,7 @@ 6428EF282AB0856400F54F59 /* DXInstrumentProfileConnectionState+Ext.swift in Sources */, 64BDDB222AD6CC9A00694210 /* SpreadOrder.swift in Sources */, 640C3FCE2A61788500555161 /* CandleExchange.swift in Sources */, - 641BCBBC2A20ED8100FE23C2 /* DXEndpointObserver.swift in Sources */, + 641BCBBC2A20ED8100FE23C2 /* DXEndpointListener.swift in Sources */, 6486B9792AD04F4000D8D5FA /* OrderBase.swift in Sources */, 64656F772A1DFED9006A0B19 /* EndpointState+Native.swift in Sources */, 6498E6B52AB1D4480093A065 /* NativeSchedule.swift in Sources */, diff --git a/DXFeedFramework/Api/DXEndpoint.swift b/DXFeedFramework/Api/DXEndpoint.swift index 32216655b..8f36ab76c 100644 --- a/DXFeedFramework/Api/DXEndpoint.swift +++ b/DXFeedFramework/Api/DXEndpoint.swift @@ -186,8 +186,8 @@ public class DXEndpoint { private lazy var publisher: DXPublisher? = { try? DXPublisher(native: endpointNative.getNativePublisher()) }() - /// A list of state change listeners callback. observersSet - not typed variable(as storage). - private var observersSet = ConcurrentWeakHashTable() + /// A list of state change listeners callback. listeneresSet - not typed variable(as storage). + private var listeneresSet = ConcurrentWeakHashTable() private static var instances = [Role: DXEndpoint]() @@ -202,18 +202,18 @@ public class DXEndpoint { try native.addListener(self) } /// Adds listener that is notified about changes in ``getState()`` property. - /// Installed listener can be removed with ``remove(_:)`` method. - public func add(observer: O) - where O: DXEndpointObserver, + /// Installed listener can be removed with ``remove(listener:)`` method. + public func add(listener: O) + where O: DXEndpointListener, O: Hashable { - observersSet.insert(observer) + listeneresSet.insert(listener) } /// Removes listener that is notified about changes in ``getState()`` property. - /// It removes the listener that was previously installed with ``add(observer:)`` method. - public func remove(_ observer: O) - where O: DXEndpointObserver, + /// It removes the listener that was previously installed with ``add(listener:)`` method. + public func remove(listener: O) + where O: DXEndpointListener, O: Hashable { - observersSet.remove(observer) + listeneresSet.remove(listener) } /// Creates new ``Builder`` instance. /// Use ``Builder/build()`` to build an instance of ``DXEndpoint`` when @@ -248,8 +248,8 @@ public class DXEndpoint { /// **This method does not wait until connection actually gets established**. The actual connection establishment /// happens asynchronously after the invocation of this method. However, this method waits until notification /// about state transition from ``DXEndpointState/notConnected`` to ``DXEndpointState/connecting`` - /// gets processed by all ``DXEndpointObserver`` that were installed via - /// ``add(observer:)`` method. + /// gets processed by all ``DXEndpointListener`` that were installed via + /// ``add(listener:)`` method. /// - Parameters: /// - address: The data source address. /// - Returns: ``DXEndpoint`` @@ -267,7 +267,7 @@ public class DXEndpoint { /// /// **Note:** The method will not connect endpoint that was not initially connected with /// ``connect(_:)`` method or was disconnected with ``disconnect()`` method. - /// The method initiates a short-path way for reconnecting, so whether observers will have a chance to see + /// The method initiates a short-path way for reconnecting, so whether listeners will have a chance to see /// an intermediate state ``DXEndpointState/notConnected`` depends on the implementation. /// - Throws: GraalException. Rethrows exception from Java.recore public func reconnect() throws { @@ -514,10 +514,10 @@ public class Builder { extension DXEndpoint: EndpointListener { func changeState(old: DXEndpointState, new: DXEndpointState) { - observersSet.reader { + listeneresSet.reader { let enumerator = $0.objectEnumerator() - while let observer = enumerator.nextObject() as? DXEndpointObserver { - observer.endpointDidChangeState(old: old, new: new) + while let listener = enumerator.nextObject() as? DXEndpointListener { + listener.endpointDidChangeState(old: old, new: new) } } } diff --git a/DXFeedFramework/Api/DXEndpointObserver.swift b/DXFeedFramework/Api/DXEndpointListener.swift similarity index 83% rename from DXFeedFramework/Api/DXEndpointObserver.swift rename to DXFeedFramework/Api/DXEndpointListener.swift index 43ce1459b..ca54cf0fc 100644 --- a/DXFeedFramework/Api/DXEndpointObserver.swift +++ b/DXFeedFramework/Api/DXEndpointListener.swift @@ -1,5 +1,5 @@ // -// DXEndpointObserver.swift +// DXEndpointListener.swift // DXFeedFramework // // Created by Aleksey Kosylo on 26.05.23. @@ -8,7 +8,7 @@ import Foundation /// Notifies a change in the state of this endpoint. -public protocol DXEndpointObserver: AnyObject { +public protocol DXEndpointListener: AnyObject { /// Fired when state changed /// /// - Parameters: diff --git a/DXFeedFramework/Api/DXFeedSubcription.swift b/DXFeedFramework/Api/DXFeedSubcription.swift index 9ad2e08e9..af337da6a 100644 --- a/DXFeedFramework/Api/DXFeedSubcription.swift +++ b/DXFeedFramework/Api/DXFeedSubcription.swift @@ -16,7 +16,7 @@ public class DXFeedSubcription { /// List of event types associated with this ``DXFeedSubscription`` fileprivate let events: Set /// A set listeners of events - /// observers - typed list wrapper. + /// listeners - typed list wrapper. private let listeners = ConcurrentWeakHashTable() /// - Throws: ``GraalException`` Rethrows exception from Java, ``ArgumentException/argumentNil`` @@ -36,7 +36,7 @@ public class DXFeedSubcription { /// /// [Javadoc](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXFeedSubscription.html#addEventListener-com.dxfeed.api.DXFeedEventListener) /// - Throws: ``GraalException`` Rethrows exception from Java, ``ArgumentException/argumentNil`` - public func add(observer: O) throws + public func add(listener: O) throws where O: DXEventListener, O: Hashable { try listeners.reader { [weak self] in @@ -44,15 +44,15 @@ public class DXFeedSubcription { try self?.native.addListener(self) } } - listeners.insert(observer) + listeners.insert(listener) } /// Removes listener for events. /// /// [Javadoc](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXFeedSubscription.html#addEventListener-com.dxfeed.api.DXFeedEventListener-) - public func remove(observer: O) + public func remove(listener: O) where O: DXEventListener, O: Hashable { - listeners.remove(observer) + listeners.remove(listener) } /// Adds the specified symbol to the set of subscribed symbols. @@ -97,8 +97,8 @@ extension DXFeedSubcription: DXEventListener { public func receiveEvents(_ events: [MarketEvent]) { listeners.reader { items in let enumerator = items.objectEnumerator() - while let observer = enumerator.nextObject() as? DXEventListener { - observer.receiveEvents(events) + while let listener = enumerator.nextObject() as? DXEventListener { + listener.receiveEvents(events) } } } diff --git a/DXFeedFramework/Ipf/Live/DXInstrumentProfileCollector.swift b/DXFeedFramework/Ipf/Live/DXInstrumentProfileCollector.swift index 86f15dfed..3fe44f5d3 100644 --- a/DXFeedFramework/Ipf/Live/DXInstrumentProfileCollector.swift +++ b/DXFeedFramework/Ipf/Live/DXInstrumentProfileCollector.swift @@ -15,7 +15,7 @@ import Foundation /// /// As set of instrument profiles stored in this collector can be accessed with ``view()`` method. /// A snapshot plus a live stream of updates can be accessed with -/// ``add(observer:)`` method. +/// ``add(listener:)`` method. /// /// Removal of instrument profile is represented by an ``InstrumentProfile`` instance with a /// ``InstrumentProfile/type`` equal to ``InstrumentProfileType/removed`` @@ -34,20 +34,20 @@ public class DXInstrumentProfileCollector { /// If a set of instrument profiles is not empty, then this listener will be immediately /// ``DXInstrumentProfileUpdateListener/instrumentProfilesUpdated(_:)``. /// - Throws: GraalException. Rethrows exception from Java. - public func add(observer: O) throws + public func add(listener: O) throws where O: DXInstrumentProfileUpdateListener, O: Hashable { - try native.addListener(observer) - listeners.insert(observer) + try native.addListener(listener) + listeners.insert(listener) } /// Removes listener that is notified about any updates in the set of instrument profiles. /// - Throws: GraalException. Rethrows exception from Java. - public func remove(observer: O) + public func remove(listener: O) where O: DXInstrumentProfileUpdateListener, O: Hashable { - native.removeListener(observer) - listeners.remove(observer) + native.removeListener(listener) + listeners.remove(listener) } /// Returns last modification time (in milliseconds) of instrument profiles or zero if it is unknown. diff --git a/DXFeedFramework/Ipf/Live/DXInstrumentProfileConnection.swift b/DXFeedFramework/Ipf/Live/DXInstrumentProfileConnection.swift index 932b50f54..1ec7e66e3 100644 --- a/DXFeedFramework/Ipf/Live/DXInstrumentProfileConnection.swift +++ b/DXFeedFramework/Ipf/Live/DXInstrumentProfileConnection.swift @@ -25,7 +25,7 @@ public class DXInstrumentProfileConnection { private let native: NativeInstrumentProfileConnection private let collector: DXInstrumentProfileCollector - private var observersSet = ConcurrentWeakHashTable() + private var listenersSet = ConcurrentWeakHashTable() /// Creates instrument profile connection with a specified address and collector. /// @@ -111,32 +111,32 @@ public class DXInstrumentProfileConnection { native.waitUntilCompleted(timeInMs) } - /// Adds observer that is notified about changes in ``getState()`` property. - /// Installed observer can be removed with - /// ``remove(observer:)`` method. - public func add(observer: O) - where O: DXInstrumentProfileConnectionObserver, + /// Adds listener that is notified about changes in ``getState()`` property. + /// Installed listener can be removed with + /// ``remove(listener:)`` method. + public func add(listener: O) + where O: DXInstrumentProfileConnectionListener, O: Hashable { - observersSet.insert(observer) + listenersSet.insert(listener) } - /// Removes observer that is notified about changes in ``getState()`` property. - /// It removes the observer that was previously installed with - /// ``add(observer:)`` method. - public func remove(observer: O) - where O: DXInstrumentProfileConnectionObserver, + /// Removes listener that is notified about changes in ``getState()`` property. + /// It removes the listener that was previously installed with + /// ``add(listener:)`` method. + public func remove(listener: O) + where O: DXInstrumentProfileConnectionListener, O: Hashable { - observersSet.remove(observer) + listenersSet.remove(listener) } } extension DXInstrumentProfileConnection: NativeIPFConnectionListener { func connectionDidChangeState(old: DXInstrumentProfileConnectionState, new: DXInstrumentProfileConnectionState) { - observersSet.reader { items in + listenersSet.reader { items in let enumerator = items.objectEnumerator() - while let observer = enumerator.nextObject() as? DXInstrumentProfileConnectionObserver { - observer.connectionDidChangeState(old: old, new: new) + while let listener = enumerator.nextObject() as? DXInstrumentProfileConnectionListener { + listener.connectionDidChangeState(old: old, new: new) } } } diff --git a/DXFeedFramework/Ipf/Live/DXInstrumentProfileConnectionObserver.swift b/DXFeedFramework/Ipf/Live/DXInstrumentProfileConnectionListener.swift similarity index 78% rename from DXFeedFramework/Ipf/Live/DXInstrumentProfileConnectionObserver.swift rename to DXFeedFramework/Ipf/Live/DXInstrumentProfileConnectionListener.swift index 548f32b88..b58cd4057 100644 --- a/DXFeedFramework/Ipf/Live/DXInstrumentProfileConnectionObserver.swift +++ b/DXFeedFramework/Ipf/Live/DXInstrumentProfileConnectionListener.swift @@ -1,5 +1,5 @@ // -// DXInstrumentProfileConnectionObserver.swift +// DXInstrumentProfileConnectionListener.swift // DXFeedFramework // // Created by Aleksey Kosylo on 01.09.23. @@ -8,7 +8,7 @@ import Foundation /// Notifies a change in the state of this connection. -public protocol DXInstrumentProfileConnectionObserver: AnyObject { +public protocol DXInstrumentProfileConnectionListener: AnyObject { /// Fired when state changed /// /// - Parameters: diff --git a/DXFeedFrameworkTests/CandleTests.swift b/DXFeedFrameworkTests/CandleTests.swift index 5cadd6992..a0a35aea2 100644 --- a/DXFeedFrameworkTests/CandleTests.swift +++ b/DXFeedFrameworkTests/CandleTests.swift @@ -71,7 +71,7 @@ final class CandleTests: XCTestCase { } return anonymCl } - try subscription?.add(observer: listener) + try subscription?.add(listener: listener) try subscription?.addSymbols(symbol) wait(for: [receivedEventExp], timeout: 10) try? endpoint?.disconnect() @@ -193,7 +193,7 @@ final class CandleTests: XCTestCase { } return anonymCl } - try subscription?.add(observer: listener) + try subscription?.add(listener: listener) try subscription?.addSymbols(symbol) wait(for: [beginEventsExp, endEventsExp], timeout: 10) try? endpoint?.disconnect() @@ -223,7 +223,7 @@ final class CandleTests: XCTestCase { testDelegate.wasSnapshotExpect = snapshotExpect testDelegate.wasUpdateExpect = updateExpect snapshotProcessor.add(testDelegate) - try subscription?.add(observer: snapshotProcessor) + try subscription?.add(listener: snapshotProcessor) try subscription?.addSymbols(symbol) wait(for: [snapshotExpect, updateExpect], timeout: 10) try? endpoint?.disconnect() diff --git a/DXFeedFrameworkTests/DXConnectionStateTests.swift b/DXFeedFrameworkTests/DXConnectionStateTests.swift index d0114d36c..53fbdcea7 100644 --- a/DXFeedFrameworkTests/DXConnectionStateTests.swift +++ b/DXFeedFrameworkTests/DXConnectionStateTests.swift @@ -39,7 +39,7 @@ final class DXConnectionStateTests: XCTestCase { DXEndpointState.connecting: expectation(description: "Connecting"), DXEndpointState.notConnected: expectation(description: "NotConnected")] let listener = TestListener(expectations: expectations) - endpoint?.add(observer: listener) + endpoint?.add(listener: listener) let exps = Array(expectations.filter({ element in element.key != .notConnected }).values) @@ -94,7 +94,7 @@ final class DXConnectionStateTests: XCTestCase { let expectations = [DXEndpointState.connected: expectation(description: "Connected"), DXEndpointState.connecting: expectation(description: "Connecting")] let listener = TestListener(expectations: expectations) - endpoint?.add(observer: listener) + endpoint?.add(listener: listener) try endpoint?.connect(":4777") let exps = Array(expectations.filter({ element in element.key != .notConnected diff --git a/DXFeedFrameworkTests/FeedTest.swift b/DXFeedFrameworkTests/FeedTest.swift index d885e3c79..bddc80d81 100644 --- a/DXFeedFrameworkTests/FeedTest.swift +++ b/DXFeedFrameworkTests/FeedTest.swift @@ -75,7 +75,7 @@ final class FeedTest: XCTestCase { } return anonymCl } - try subscription?.add(observer: listener) + try subscription?.add(listener: listener) XCTAssertNotNil(subscription, "Subscription shouldn't be nil") try subscription?.addSymbols(symbols) wait(for: [receivedEventExp], timeout: 5) @@ -174,7 +174,7 @@ final class FeedTest: XCTestCase { } return anonymCl } - try subscription?.add(observer: listener) + try subscription?.add(listener: listener) try subscription?.addSymbols(["ETH/USD:GDAX", "IBM"]) wait(for: [receivedEventExp], timeout: 10) } diff --git a/DXFeedFrameworkTests/IPFTests.swift b/DXFeedFrameworkTests/IPFTests.swift index de0d2859e..e2192af76 100644 --- a/DXFeedFrameworkTests/IPFTests.swift +++ b/DXFeedFrameworkTests/IPFTests.swift @@ -28,7 +28,7 @@ final class IPFTests: XCTestCase { } } - class AnonymousConnectionListener: DXInstrumentProfileConnectionObserver, Hashable { + class AnonymousConnectionListener: DXInstrumentProfileConnectionListener, Hashable { static func == (lhs: AnonymousConnectionListener, rhs: AnonymousConnectionListener) -> Bool { lhs === rhs } @@ -218,10 +218,10 @@ STOCK,EREGL:TR,EREĞLİ DEMİR VE ÇELİK FABRİKALARI1 T.A.Ş.,TR,XIST,XIST,TRY } try collector.updateInstrumentProfile(profile: bothListnersProfile) wait(seconds: 1) - try collector.add(observer: listener) - try collector.add(observer: listener2) + try collector.add(listener: listener) + try collector.add(listener: listener2) wait(for: [expectation1, expectation2], timeout: 2.0) - collector.remove(observer: listener2) + collector.remove(listener: listener2) try collector.updateInstrumentProfile(profile: firstListnerProfile) wait(for: [expectation3], timeout: 2.0) } @@ -244,7 +244,7 @@ STOCK,EREGL:TR,EREĞLİ DEMİR VE ÇELİK FABRİKALARI1 T.A.Ş.,TR,XIST,XIST,TRY let expectationCollector = expectation(description: "Collector") expectationCollector.assertForOverFulfill = false let collector = try DXInstrumentProfileCollector() - let collectorObserver = AnonymousProfileListener { anonymCl in + let collectorListener = AnonymousProfileListener { anonymCl in anonymCl.callback = { profiles in if profiles.count > 0 { expectationCollector.fulfill() @@ -252,11 +252,11 @@ STOCK,EREGL:TR,EREĞLİ DEMİR VE ÇELİK FABRİKALARI1 T.A.Ş.,TR,XIST,XIST,TRY } return anonymCl } - try collector.add(observer: collectorObserver) + try collector.add(listener: collectorListener) let expectationConnection = expectation(description: "Connection") expectationConnection.expectedFulfillmentCount = 3 // connecting, connected, completed let connection = try DXInstrumentProfileConnection(address, collector) - let connectionObserver = AnonymousConnectionListener { anonymCl in + let connectionListener = AnonymousConnectionListener { anonymCl in anonymCl.callback = { _, new in switch new { case .notConnected: @@ -273,7 +273,7 @@ STOCK,EREGL:TR,EREĞLİ DEMİR VE ÇELİK FABRİKALARI1 T.A.Ş.,TR,XIST,XIST,TRY } return anonymCl } - connection.add(observer: connectionObserver) + connection.add(listener: connectionListener) try connection.start() wait(for: [expectationConnection, expectationCollector], timeout: 20.0) } diff --git a/DXFeedFrameworkTests/Listeners/TestEndpoointStateListener.swift b/DXFeedFrameworkTests/Listeners/TestEndpoointStateListener.swift index 32d4cd208..d2b9de7b9 100644 --- a/DXFeedFrameworkTests/Listeners/TestEndpoointStateListener.swift +++ b/DXFeedFrameworkTests/Listeners/TestEndpoointStateListener.swift @@ -8,7 +8,7 @@ import Foundation @testable import DXFeedFramework -class TestEndpoointStateListener: DXEndpointObserver, Hashable { +class TestEndpoointStateListener: DXEndpointListener, Hashable { func endpointDidChangeState(old: DXFeedFramework.DXEndpointState, new: DXFeedFramework.DXEndpointState) { callback(new) } diff --git a/DXFeedFrameworkTests/Listeners/TestListener.swift b/DXFeedFrameworkTests/Listeners/TestListener.swift index fc4b5104c..566674c1c 100644 --- a/DXFeedFrameworkTests/Listeners/TestListener.swift +++ b/DXFeedFrameworkTests/Listeners/TestListener.swift @@ -9,7 +9,7 @@ import Foundation import XCTest @testable import DXFeedFramework -class TestListener: DXEndpointObserver { +class TestListener: DXEndpointListener { var expectations: [DXEndpointState: XCTestExpectation] init(expectations: [DXEndpointState: XCTestExpectation]) { self.expectations = expectations diff --git a/DXFeedFrameworkTests/PublisherTest.swift b/DXFeedFrameworkTests/PublisherTest.swift index b81099542..c40c16089 100644 --- a/DXFeedFrameworkTests/PublisherTest.swift +++ b/DXFeedFrameworkTests/PublisherTest.swift @@ -55,7 +55,7 @@ final class PublisherTest: XCTestCase { return listener } - feedEndpoint.add(observer: stateListener!) + feedEndpoint.add(listener: stateListener!) let subscription = try feedEndpoint.getFeed()?.createSubscription(.quote) try feedEndpoint.connect("localhost:7400") let receivedEventExp = expectation(description: "Received events \(EventCode.quote)") @@ -68,7 +68,7 @@ final class PublisherTest: XCTestCase { return anonymCl } - try subscription?.add(observer: listener) + try subscription?.add(listener: listener) try subscription?.addSymbols(["AAPL"]) wait(for: [connectedExpectation], timeout: 1) wait(for: [receivedEventExp], timeout: 20) diff --git a/Samples/IpfTableApp/ViewController.swift b/Samples/IpfTableApp/ViewController.swift index 54ca4d780..3df338573 100644 --- a/Samples/IpfTableApp/ViewController.swift +++ b/Samples/IpfTableApp/ViewController.swift @@ -52,12 +52,12 @@ class ViewController: UIViewController { connection = try DXInstrumentProfileConnection(addressTextField.text ?? "", collector!) // Update period can be used to re-read IPF files, not needed for services supporting IPF "live-update" try connection?.setUpdatePeriod(60000) - connection?.add(observer: self) + connection?.add(listener: self) try connection?.start() // We can wait until we get first full snapshot of instrument profiles connection?.waitUntilCompleted(5000) // It is possible to add listener after connection is started - updates will not be missed in this case - try collector?.add(observer: self) + try collector?.add(listener: self) } catch { print("Error during creation IPF data source: \(error)") } @@ -71,7 +71,7 @@ class ViewController: UIViewController { } } -extension ViewController: DXInstrumentProfileConnectionObserver { +extension ViewController: DXInstrumentProfileConnectionListener { func connectionDidChangeState(old: DXFeedFramework.DXInstrumentProfileConnectionState, new: DXFeedFramework.DXInstrumentProfileConnectionState) { DispatchQueue.main.async { diff --git a/Samples/LatencyTestApp/LatencyViewController.swift b/Samples/LatencyTestApp/LatencyViewController.swift index 4cf4ea4a4..d772d177d 100644 --- a/Samples/LatencyTestApp/LatencyViewController.swift +++ b/Samples/LatencyTestApp/LatencyViewController.swift @@ -72,11 +72,11 @@ class LatencyViewController: UIViewController { return } endpoint = try? DXEndpoint.builder().withRole(.feed).build() - endpoint?.add(observer: self) + endpoint?.add(listener: self) _ = try? endpoint?.connect(address) subscription = try? endpoint?.getFeed()?.createSubscription(.timeAndSale) - try? subscription?.add(observer: listener) + try? subscription?.add(listener: listener) try? subscription?.addSymbols(symbols) listener.cleanTime() @@ -109,7 +109,7 @@ class LatencyViewController: UIViewController { } } -extension LatencyViewController: DXEndpointObserver { +extension LatencyViewController: DXEndpointListener { func endpointDidChangeState(old: DXEndpointState, new: DXEndpointState) { DispatchQueue.main.async { self.isConnected = new == .connected diff --git a/Samples/PertTestApp/PerfTestViewController.swift b/Samples/PertTestApp/PerfTestViewController.swift index adcf83171..c242b5ce5 100644 --- a/Samples/PertTestApp/PerfTestViewController.swift +++ b/Samples/PertTestApp/PerfTestViewController.swift @@ -114,18 +114,18 @@ class PerfTestViewController: UIViewController { return } endpoint = try? DXEndpoint.builder().withRole(.feed).build() - endpoint?.add(observer: self) + endpoint?.add(listener: self) _ = try? endpoint?.connect(address) subscription = try? endpoint?.getFeed()?.createSubscription(.timeAndSale) - try? subscription?.add(observer: listener) + try? subscription?.add(listener: listener) try? subscription?.addSymbols(symbolsTextField.text ?? "") listener.cleanTime() } } } -extension PerfTestViewController: DXEndpointObserver { +extension PerfTestViewController: DXEndpointListener { func endpointDidChangeState(old: DXEndpointState, new: DXEndpointState) { DispatchQueue.main.async { self.isConnected = new == .connected diff --git a/Samples/QuoteTableApp/QuoteTableViewController.swift b/Samples/QuoteTableApp/QuoteTableViewController.swift index 3c18c1e1e..4f83aca2d 100644 --- a/Samples/QuoteTableApp/QuoteTableViewController.swift +++ b/Samples/QuoteTableApp/QuoteTableViewController.swift @@ -47,13 +47,13 @@ class QuoteTableViewController: UIViewController { _ = try? builder?.withProperty(DXEndpoint.Property.aggregationPeriod.rawValue, "1") } endpoint = try? builder?.build() - endpoint?.add(observer: self) + endpoint?.add(listener: self) _ = try? endpoint?.connect("demo.dxfeed.com:7300") subscription = try? endpoint?.getFeed()?.createSubscription(.quote) profileSubscription = try? endpoint?.getFeed()?.createSubscription(.profile) - try? subscription?.add(observer: self) - try? profileSubscription?.add(observer: self) + try? subscription?.add(listener: self) + try? profileSubscription?.add(listener: self) symbols.forEach { dataSource[$0] = QuoteModel() } @@ -66,7 +66,7 @@ class QuoteTableViewController: UIViewController { } } -extension QuoteTableViewController: DXEndpointObserver { +extension QuoteTableViewController: DXEndpointListener { func endpointDidChangeState(old: DXEndpointState, new: DXEndpointState) { DispatchQueue.main.async { self.connectionStatusLabel.text = new.convetToString() diff --git a/Samples/QuoteTableApp/QuoteViewController.swift b/Samples/QuoteTableApp/QuoteViewController.swift index b610c82d7..225ee70a2 100644 --- a/Samples/QuoteTableApp/QuoteViewController.swift +++ b/Samples/QuoteTableApp/QuoteViewController.swift @@ -47,7 +47,7 @@ class QuoteViewController: UIViewController { } if endpoint == nil { endpoint = try? DXEndpoint.builder().withRole(.feed).build() - endpoint?.add(observer: self) + endpoint?.add(listener: self) } _ = try? endpoint?.connect(address) } @@ -67,12 +67,12 @@ class QuoteViewController: UIViewController { symbolTextField.resignFirstResponder() subscription = try? endpoint?.getFeed()?.createSubscription(.timeAndSale) - try? subscription?.add(observer: self) + try? subscription?.add(listener: self) try? subscription?.addSymbols(symbol) } } -extension QuoteViewController: DXEndpointObserver { +extension QuoteViewController: DXEndpointListener { func endpointDidChangeState(old: DXEndpointState, new: DXEndpointState) { isConnected = new == .connected updateConnectButton() diff --git a/Samples/Tools/DumpTool.swift b/Samples/Tools/DumpTool.swift index c4daca286..9a36ca4d4 100644 --- a/Samples/Tools/DumpTool.swift +++ b/Samples/Tools/DumpTool.swift @@ -81,7 +81,7 @@ class DumpTool: ToolsCommand { publisher = outputEndpoint?.getPublisher() } - try subscription?.add(observer: self) + try subscription?.add(listener: self) try subscription?.addSymbols(symbols) try inputEndpoint.connect(address) diff --git a/Samples/Tools/IpfConnect.swift b/Samples/Tools/IpfConnect.swift index 46c10eadf..2ca04576b 100644 --- a/Samples/Tools/IpfConnect.swift +++ b/Samples/Tools/IpfConnect.swift @@ -44,7 +44,7 @@ class IpfConnect: ToolsCommand { let ipfFile = arguments[2] try? SystemProperty.setProperty(DXEndpoint.Property.address.rawValue, "demo.dxfeed.com:7300") let subscription = try? DXEndpoint.getInstance().getFeed()?.createSubscription([EventCode(string: eventType)]) - try? subscription?.add(observer: self) + try? subscription?.add(listener: self) let symbols = getSymbols(fileName: ipfFile) try? subscription?.addSymbols(symbols) // Print till input new line diff --git a/Samples/Tools/LiveIpfSample.swift b/Samples/Tools/LiveIpfSample.swift index 11bc1eaa5..30b3e0895 100644 --- a/Samples/Tools/LiveIpfSample.swift +++ b/Samples/Tools/LiveIpfSample.swift @@ -55,12 +55,12 @@ class LiveIpfSample: ToolsCommand { connection = try DXInstrumentProfileConnection(arguments.count > 1 ? arguments[1] : LiveIpfSample.defaultIpfUrl, collector!) // Update period can be used to re-read IPF files, not needed for services supporting IPF "live-update" try connection?.setUpdatePeriod(60000) - connection?.add(observer: self) + connection?.add(listener: self) try connection?.start() // We can wait until we get first full snapshot of instrument profiles connection?.waitUntilCompleted(10000) // It is possible to add listener after connection is started - updates will not be missed in this case - try collector?.add(observer: self) + try collector?.add(listener: self) } catch { print("Error: \(error)") } @@ -69,7 +69,7 @@ class LiveIpfSample: ToolsCommand { } } -extension LiveIpfSample: DXInstrumentProfileConnectionObserver { +extension LiveIpfSample: DXInstrumentProfileConnectionListener { func connectionDidChangeState(old: DXInstrumentProfileConnectionState, new: DXInstrumentProfileConnectionState) { print("Connection state: \(new)") } diff --git a/Samples/Tools/SubscriptionUtils.swift b/Samples/Tools/SubscriptionUtils.swift index 7cdfe314e..69e3499a7 100644 --- a/Samples/Tools/SubscriptionUtils.swift +++ b/Samples/Tools/SubscriptionUtils.swift @@ -30,7 +30,7 @@ Create subscription to \(address) for \(types):\(symbols) with properties:\(prop _ = try? endpoint?.connect(address) types.forEach { str in let subscription = try? endpoint?.getFeed()?.createSubscription(str) - try? subscription?.add(observer: listener) + try? subscription?.add(listener: listener) if time != nil { guard let date = TimeUtil.parse(time!) else { fatalError("Couldn't parse string \(time ?? "") to Date object")