Skip to content

Commit

Permalink
create endpoint only at first time
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed Mar 22, 2024
1 parent a552f09 commit e2e8508
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
9 changes: 4 additions & 5 deletions Samples/QuoteTableApp/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,8 @@
</connections>
</switch>
<button opaque="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" contentHorizontalAlignment="fill" contentVerticalAlignment="fill" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="er8-zz-YEu">
<rect key="frame" x="343" y="58.666666666666657" width="40" height="35"/>
<rect key="frame" x="337" y="58.666666666666657" width="46" height="35"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="4Pc-Oc-hIj"/>
<constraint firstAttribute="height" constant="35" id="jDE-l3-0g0"/>
</constraints>
<state key="normal" title="Button"/>
Expand Down Expand Up @@ -321,7 +320,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cbg-fQ-Qn4">
<rect key="frame" x="0.0" y="0.0" width="353" height="90"/>
<rect key="frame" x="10" y="0.0" width="353" height="90"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="--------------" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ybg-Bu-TvM">
<rect key="frame" x="10" y="0.0" width="333" height="90"/>
Expand All @@ -341,8 +340,8 @@
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="Cbg-fQ-Qn4" secondAttribute="bottom" constant="10" id="Ay3-cZ-fSy"/>
<constraint firstAttribute="trailing" secondItem="Cbg-fQ-Qn4" secondAttribute="trailing" constant="20" symbolic="YES" id="MQP-kV-3o6"/>
<constraint firstItem="Cbg-fQ-Qn4" firstAttribute="leading" secondItem="3S8-DK-dno" secondAttribute="leading" id="n3Z-BQ-GI7"/>
<constraint firstAttribute="trailing" secondItem="Cbg-fQ-Qn4" secondAttribute="trailing" constant="10" id="MQP-kV-3o6"/>
<constraint firstItem="Cbg-fQ-Qn4" firstAttribute="leading" secondItem="3S8-DK-dno" secondAttribute="leading" constant="10" id="n3Z-BQ-GI7"/>
<constraint firstItem="Cbg-fQ-Qn4" firstAttribute="top" secondItem="3S8-DK-dno" secondAttribute="top" id="nKb-Lk-Uo1"/>
</constraints>
</tableViewCellContentView>
Expand Down
25 changes: 11 additions & 14 deletions Samples/QuoteTableApp/QuoteTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,20 @@ class QuoteTableViewController: UIViewController {
func subscribe(_ unlimited: Bool) {
print("UI Current thread \(Thread.current)")

if endpoint != nil {
try? endpoint?.disconnect()
// try? endpoint?.disconnectAndClear()
// try? endpoint?.close()
if endpoint == nil {
try? SystemProperty.setProperty(DXEndpoint.ExtraPropery.heartBeatTimeout.rawValue, "15s")

let builder = try? DXEndpoint.builder().withRole(.feed)
if !unlimited {
_ = try? builder?.withProperty(DXEndpoint.Property.aggregationPeriod.rawValue, "1")
}
endpoint = try? builder?.build()
endpoint?.add(listener: self)
_ = try? endpoint?.connect("demo.dxfeed.com:7300")
} else {
subscription = nil
profileSubscription = nil
}
try? SystemProperty.setProperty(DXEndpoint.ExtraPropery.heartBeatTimeout.rawValue, "15s")

let builder = try? DXEndpoint.builder().withRole(.feed)
if !unlimited {
_ = try? builder?.withProperty(DXEndpoint.Property.aggregationPeriod.rawValue, "1")
}
endpoint = try? builder?.build()
endpoint?.add(listener: self)
_ = try? endpoint?.connect("demo.dxfeed.com:7300")

subscription = try? endpoint?.getFeed()?.createSubscription(Quote.self)
profileSubscription = try? endpoint?.getFeed()?.createSubscription(Profile.self)
Expand All @@ -89,7 +87,6 @@ class QuoteTableViewController: UIViewController {
if let newView = self.storyboard?.instantiateViewController(withIdentifier: "SymbolsViewController") as? SymbolsViewController {
self.navigationController?.pushViewController(newView, animated: true)
}

}
}

Expand Down

0 comments on commit e2e8508

Please sign in to comment.