Skip to content

Commit

Permalink
v0.1.0 (#47)
Browse files Browse the repository at this point in the history
* feat: add decoding capability in case of failure caused due to HTTP status code

Resolves: none.

* feat: override User-Agent HTTP header in session configuration (#26)

Resolves: none.

* Add macOS example (#27)

* feat: move iOS example project into new sub folder

Resolves: none.

* fix: update framework search paths

Resolves: none.

* feat: add empt macOS example project to workspace

Resolves: none.

* fix: update framework scheme name

Resolves: none.

* feat: add files to macOS example directory

Resolves: none.

* fix: apply public access modifier to DefaultHTTPErrorBody and DefaultNetworkAPIError

Resolves: none.

* refactor: add description comment for ProcessInfo extension

Resolves: none.

* fix: add RxNetworkKit bridging header reference

Resolves: none.

* refactor: apply project recommended settings

Resolves: none.

* feat: connect viewModel to tableview UI

Resolves: none.

* feat: complete ViewController class in macOS Example

Resolves: none.

* refactor: remove old un-needed file

Resolves: none.

* fix: apply correct image scale for error view

Resolves: none.

* Apply new version (0.0.2) (#28)

* fix: remove tinted button warning

Resolves: none.

* version: 0.0.2

Resolves: none.

* fix: update version for podSpec file

Resolves: none.

* fix: remove RxDataSources import statement (#31)

Resolves: none.

* Add CI Workflows For Repository (#33)

* feat: add iOS workflow

Resolves: none.

* fix: update build-ios.yml

Resolves: none.

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Update build-ios.yml

* Create build-macos.yml

* Update build-ios.yml + build-macos.yml

* fix error 65

* Update build-ios.yml

* update build-ios.yml + build-macos.yml

* Update build-macos.yml

* Update project.pbxproj

* add publish-podspec.yml

* add workflow files outside of folders

* Update publish-podspec.yml

* Update publish-podspec.yml

* Update publish-podspec.yml

* Create pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* test container workflow

* Update build.yml

* Update build.yml

* add some changes

* Update build.yml

* add some changes

* Update build.yml

* refactor: update names + remove comments

Resolves: none.

* add trigger for trunk push workflow

* add dummy project to test SPM integration

* add spm-lint.yml

* Update spm-lint.yml

* Update spm-lint.yml

* Update spm-lint.yml

* Update spm-lint.yml

* update dummy project

* update workspace dependencies versions

* Update CI Workflows

* update CI workflows

* Update CI Workflow

* Update Dependency Version Rules (#45)

* fix: update version rules for SPM to upToNextMajor

Resolves: none.

* fix: update version rule for SPM in iOS Example project

Resolves: none.

* fix: update version rules for cocoapods in podspec file

Resolves: none.

* feat: add WebSocket capability to NetworkManager (#46)

Resolves: none.

* fix a typo

* update dependencies versions

Resolves: none.

* update Package.swift + podspec file

* change xcode version used in CI/CD to 14.3.1

Resolves: none.

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update build.yml

* Update build.yml

* update workflow files

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-lib-lint.yml

* Update pod-trunk-push.yml

* Update spm-lint.yml
  • Loading branch information
loay-ashraf committed Oct 4, 2023
1 parent 0b6c001 commit 9e84cbb
Show file tree
Hide file tree
Showing 18 changed files with 339 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-ios.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
xcode-version: '14.3.1'
- name: Build Framework
env:
workspace: RxNetworkKit.xcworkspace
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Set Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
xcode-version: '14.3.1'
- name: Build Framework
env:
workspace: RxNetworkKit.xcworkspace
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Set Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
xcode-version: '14.3.1'
- name: Build Example
env:
workspace: RxNetworkKit.xcworkspace
Expand All @@ -73,7 +73,7 @@ jobs:
- name: Set Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
xcode-version: '14.3.1'
- name: Build Example
env:
workspace: RxNetworkKit.xcworkspace
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-macos.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
xcode-version: '14.3.1'
- name: Build Framework
env:
workspace: RxNetworkKit.xcworkspace
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Set Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
xcode-version: '14.3.1'
- name: Build Example
env:
workspace: RxNetworkKit.xcworkspace
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pod-lib-lint.yml
Expand Up @@ -23,7 +23,13 @@ jobs:
- name: Set Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '14.2'
xcode-version: '14.3.1'
- name: Add Missing Lib Files (for iOS 9.0 and macOS 10.9)
run: |
cd /Applications/Xcode_14.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
sudo mkdir arc
cd arc
sudo git clone https://github.com/kamyarelyasi/Libarclite-Files.git .
- name: Install Cocoapods
run: |
sudo gem install cocoapods
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pod-trunk-push.yml
Expand Up @@ -21,7 +21,13 @@ jobs:
- name: Set Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '14.2'
xcode-version: '14.3.1'
- name: Add Missing Lib Files (for iOS 9.0 and macOS 10.9)
run: |
cd /Applications/Xcode_14.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
sudo mkdir arc
cd arc
sudo git clone https://github.com/kamyarelyasi/Libarclite-Files.git .
- name: Install Cocoapods
run: |
sudo gem install cocoapods
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spm-lint.yml
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
xcode-version: '14.3.1'
- name: Update Packages
run: |
swift package update
Expand Down
2 changes: 1 addition & 1 deletion Examples/iOS/iOS Example.xcodeproj/project.pbxproj
Expand Up @@ -549,7 +549,7 @@
repositoryURL = "https://github.com/RxSwiftCommunity/RxDataSources";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.0.2;
minimumVersion = 5.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Expand Up @@ -17,8 +17,8 @@ let package = Package(
.library(name: "RxNetworkKit", targets: ["RxNetworkKit"]),
],
dependencies: [
.package(url: "https://github.com/ReactiveX/RxSwift.git", .exact("6.5.0")),
.package(url: "https://github.com/RxSwiftCommunity/RxSwiftExt", .exact("6.0.1")),
.package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "6.6.0")),
.package(url: "https://github.com/RxSwiftCommunity/RxSwiftExt", .upToNextMajor(from: "6.2.0")),
],
targets: [
.target(name: "RxNetworkKit", dependencies: ["RxSwift", "RxSwiftExt", .product(name: "RxCocoa", package: "RxSwift")], path: "Source"),
Expand Down
56 changes: 50 additions & 6 deletions RxNetworkKit.xcodeproj/project.pbxproj
Expand Up @@ -62,6 +62,13 @@
C6A9BEFA2A93F16200459E32 /* URLSessionConfiguration+setAdditionalHTTPHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A9BEF92A93F16200459E32 /* URLSessionConfiguration+setAdditionalHTTPHeader.swift */; };
C6A9BEFD2A93FAF100459E32 /* URLSessionConfiguration+setUserAgentHTTPHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A9BEFC2A93FAF100459E32 /* URLSessionConfiguration+setUserAgentHTTPHeader.swift */; };
C6A9BEFF2A93FB1D00459E32 /* ProcessInfo+operatingSystemName.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A9BEFE2A93FB1D00459E32 /* ProcessInfo+operatingSystemName.swift */; };
C6BDFFE82ACDF3830022F675 /* Reactive+receive.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6BDFFE72ACDF3830022F675 /* Reactive+receive.swift */; };
C6BDFFEA2ACDF3D90022F675 /* Reactive+send.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6BDFFE92ACDF3D90022F675 /* Reactive+send.swift */; };
C6BDFFEC2ACDF4100022F675 /* Reactive+ping.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6BDFFEB2ACDF4100022F675 /* Reactive+ping.swift */; };
C6BDFFEE2ACDF46A0022F675 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6BDFFED2ACDF46A0022F675 /* WebSocket.swift */; };
C6BDFFF02ACDF4AB0022F675 /* WebSocketCloseHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6BDFFEF2ACDF4AB0022F675 /* WebSocketCloseHandler.swift */; };
C6BDFFF32ACDF5100022F675 /* WebSocketMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6BDFFF22ACDF50F0022F675 /* WebSocketMessage.swift */; };
C6BDFFF52ACDF5250022F675 /* WebSocketCloseCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6BDFFF42ACDF5250022F675 /* WebSocketCloseCode.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -118,6 +125,13 @@
C6A9BEF92A93F16200459E32 /* URLSessionConfiguration+setAdditionalHTTPHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSessionConfiguration+setAdditionalHTTPHeader.swift"; sourceTree = "<group>"; };
C6A9BEFC2A93FAF100459E32 /* URLSessionConfiguration+setUserAgentHTTPHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSessionConfiguration+setUserAgentHTTPHeader.swift"; sourceTree = "<group>"; };
C6A9BEFE2A93FB1D00459E32 /* ProcessInfo+operatingSystemName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProcessInfo+operatingSystemName.swift"; sourceTree = "<group>"; };
C6BDFFE72ACDF3830022F675 /* Reactive+receive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Reactive+receive.swift"; sourceTree = "<group>"; };
C6BDFFE92ACDF3D90022F675 /* Reactive+send.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Reactive+send.swift"; sourceTree = "<group>"; };
C6BDFFEB2ACDF4100022F675 /* Reactive+ping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Reactive+ping.swift"; sourceTree = "<group>"; };
C6BDFFED2ACDF46A0022F675 /* WebSocket.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebSocket.swift; sourceTree = "<group>"; };
C6BDFFEF2ACDF4AB0022F675 /* WebSocketCloseHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebSocketCloseHandler.swift; sourceTree = "<group>"; };
C6BDFFF22ACDF50F0022F675 /* WebSocketMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebSocketMessage.swift; sourceTree = "<group>"; };
C6BDFFF42ACDF5250022F675 /* WebSocketCloseCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebSocketCloseCode.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -155,6 +169,7 @@
0B77E04A29D965D30077FBC0 /* Source */ = {
isa = PBXGroup;
children = (
C6BDFFE62ACDF3260022F675 /* Web Socket */,
0B77E04B29D965D30077FBC0 /* Custom Requests */,
0B77E05929D965D30077FBC0 /* Request Interceptor */,
0B77E05F29D965D30077FBC0 /* Manager */,
Expand All @@ -181,9 +196,9 @@
0B77E04C29D965D30077FBC0 /* Download */ = {
isa = PBXGroup;
children = (
0B77E04D29D965D30077FBC0 /* Reactive+URLSessionDownloadResponse.swift */,
0B77E04E29D965D30077FBC0 /* DownloadEvent.swift */,
0B77E04F29D965D30077FBC0 /* URLSession+DownloadTask.swift */,
0B77E04D29D965D30077FBC0 /* Reactive+URLSessionDownloadResponse.swift */,
0B77E05029D965D30077FBC0 /* Reactive+URLSessionAdaptedDownloadResponse.swift */,
);
path = Download;
Expand All @@ -196,9 +211,9 @@
0B77E05329D965D30077FBC0 /* UploadFile.swift */,
0B77E05429D965D30077FBC0 /* URLSession+UploadTask.swift */,
0B77E05529D965D30077FBC0 /* Data+AppendString.swift */,
0B77E05629D965D30077FBC0 /* Reactive+URLSessionAdaptedUploadResponse.swift */,
0B77E05729D965D30077FBC0 /* UploadEvent.swift */,
0B77E05829D965D30077FBC0 /* Reactive+URLSessionUploadResponse.swift */,
0B77E05629D965D30077FBC0 /* Reactive+URLSessionAdaptedUploadResponse.swift */,
);
path = Upload;
sourceTree = "<group>";
Expand Down Expand Up @@ -338,6 +353,28 @@
path = Router;
sourceTree = "<group>";
};
C6BDFFE62ACDF3260022F675 /* Web Socket */ = {
isa = PBXGroup;
children = (
C6BDFFF12ACDF4CB0022F675 /* Extensions */,
C6BDFFED2ACDF46A0022F675 /* WebSocket.swift */,
C6BDFFEF2ACDF4AB0022F675 /* WebSocketCloseHandler.swift */,
C6BDFFF22ACDF50F0022F675 /* WebSocketMessage.swift */,
C6BDFFF42ACDF5250022F675 /* WebSocketCloseCode.swift */,
);
path = "Web Socket";
sourceTree = "<group>";
};
C6BDFFF12ACDF4CB0022F675 /* Extensions */ = {
isa = PBXGroup;
children = (
C6BDFFE72ACDF3830022F675 /* Reactive+receive.swift */,
C6BDFFE92ACDF3D90022F675 /* Reactive+send.swift */,
C6BDFFEB2ACDF4100022F675 /* Reactive+ping.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -427,12 +464,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C6BDFFF02ACDF4AB0022F675 /* WebSocketCloseHandler.swift in Sources */,
0B77E0AD29D965D30077FBC0 /* Single+CatchErrors.swift in Sources */,
0B77E0B529D965D30077FBC0 /* NetworkRouter.swift in Sources */,
0B77E09529D965D30077FBC0 /* RequestRetryPolicy.swift in Sources */,
0B77E0B329D965D30077FBC0 /* Reactive+Curl.swift in Sources */,
C6A9BEF82A93E2D600459E32 /* HTTPErrorBody.swift in Sources */,
0B77E0A929D965D30077FBC0 /* NetworkError.swift in Sources */,
C6BDFFEA2ACDF3D90022F675 /* Reactive+send.swift in Sources */,
0B77E09F29D965D30077FBC0 /* NWPath+InterfaceType.swift in Sources */,
0B77E09C29D965D30077FBC0 /* HTTPScheme.swift in Sources */,
0B77E0A029D965D30077FBC0 /* NetworkReachabilityStatus.swift in Sources */,
Expand All @@ -454,11 +493,13 @@
C6A9BEFD2A93FAF100459E32 /* URLSessionConfiguration+setUserAgentHTTPHeader.swift in Sources */,
0B77E09129D965D30077FBC0 /* Reactive+URLSessionAdaptedUploadResponse.swift in Sources */,
C6A9BEFA2A93F16200459E32 /* URLSessionConfiguration+setAdditionalHTTPHeader.swift in Sources */,
C6BDFFF32ACDF5100022F675 /* WebSocketMessage.swift in Sources */,
0B77E0A629D965D30077FBC0 /* DefaultNetworkAPIError.swift in Sources */,
0B77E0A429D965D30077FBC0 /* NetworkReachability.swift in Sources */,
0B77E0B229D965D30077FBC0 /* Completable+Retry.swift in Sources */,
0B77E0B029D965D30077FBC0 /* Observable+Retry.swift in Sources */,
0B77E08B29D965D30077FBC0 /* URLSession+DownloadTask.swift in Sources */,
C6BDFFF52ACDF5250022F675 /* WebSocketCloseCode.swift in Sources */,
0B77E0A729D965D30077FBC0 /* NetworkServerError.swift in Sources */,
0B77E0B629D965D30077FBC0 /* NetworkUploadRouter.swift in Sources */,
C6A9BEF62A93E2AE00459E32 /* DefaultHTTPErrorBody.swift in Sources */,
Expand All @@ -469,13 +510,16 @@
0B77E09629D965D30077FBC0 /* RequestAdapter.swift in Sources */,
0B77E0A829D965D30077FBC0 /* NetworkClientError.swift in Sources */,
0B77E0A229D965D30077FBC0 /* NWInterfaceType+CaseIterable.swift in Sources */,
C6BDFFEE2ACDF46A0022F675 /* WebSocket.swift in Sources */,
0B77E09329D965D30077FBC0 /* Reactive+URLSessionUploadResponse.swift in Sources */,
0B77E09B29D965D30077FBC0 /* HTTPMethod.swift in Sources */,
0B77E0AC29D965D30077FBC0 /* Single+Decode.swift in Sources */,
0B77E0A329D965D30077FBC0 /* NetworkInterfaceType.swift in Sources */,
0B77E09229D965D30077FBC0 /* UploadEvent.swift in Sources */,
0B77E09029D965D30077FBC0 /* Data+AppendString.swift in Sources */,
C6BDFFE82ACDF3830022F675 /* Reactive+receive.swift in Sources */,
0B77E08929D965D30077FBC0 /* Reactive+URLSessionDownloadResponse.swift in Sources */,
C6BDFFEC2ACDF4100022F675 /* Reactive+ping.swift in Sources */,
0B77E0AA29D965D30077FBC0 /* NetworkAPIError.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -709,16 +753,16 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ReactiveX/RxSwift";
requirement = {
kind = exactVersion;
version = 6.5.0;
kind = upToNextMajorVersion;
minimumVersion = 6.6.0;
};
};
0B77E0BE29D969370077FBC0 /* XCRemoteSwiftPackageReference "RxSwiftExt" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/RxSwiftCommunity/RxSwiftExt";
requirement = {
kind = exactVersion;
version = 6.0.1;
kind = upToNextMajorVersion;
minimumVersion = 6.2.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Expand Up @@ -14,17 +14,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/ReactiveX/RxSwift",
"state" : {
"revision" : "b4307ba0b6425c0ba4178e138799946c3da594f8",
"version" : "6.5.0"
"revision" : "9dcaa4b333db437b0fbfaf453fad29069044a8b4",
"version" : "6.6.0"
}
},
{
"identity" : "rxswiftext",
"kind" : "remoteSourceControl",
"location" : "https://github.com/RxSwiftCommunity/RxSwiftExt",
"state" : {
"revision" : "827bd11853983383b708feaf7da95c560982b2b8",
"version" : "6.0.1"
"revision" : "eb4adf9f00a21b3efc3869a5218a6d7517e95222",
"version" : "6.2.1"
}
}
],
Expand Down
8 changes: 4 additions & 4 deletions RxNetworkKitX.podspec
Expand Up @@ -4,17 +4,17 @@ Pod::Spec.new do |s|
s.macos.deployment_target = '11.0'
s.name = 'RxNetworkKitX'
s.module_name = 'RxNetworkKit'
s.version = '0.0.2'
s.version = '0.1.0'
s.summary = 'a lightweight FRP networking framework.'
s.description = 'a FRP networking framework built on top of URLSession and uses RxSwift and RxCocoa.'
s.homepage = 'https://github.com/loay-ashraf/RxNetworkKit'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'loay-ashraf' => 'loay.ashraf.96@gmail.com' }
s.source = { :git => 'https://github.com/loay-ashraf/RxNetworkKit.git', :tag => s.version.to_s }
s.framework = "Foundation"
s.dependency 'RxSwift', '~> 6.5.0'
s.dependency 'RxCocoa', '~> 6.5.0'
s.dependency 'RxSwiftExt', '~> 6.0.1'
s.dependency 'RxSwift', '~> 6.6'
s.dependency 'RxCocoa', '~> 6.6'
s.dependency 'RxSwiftExt', '~> 6.2'
s.source_files = 'Source/**/*.{swift,m,h}'
s.swift_version = '5.0'
end
14 changes: 14 additions & 0 deletions Source/Manager/NetworkManager.swift
Expand Up @@ -24,6 +24,7 @@ public class NetworkManager {
// Apply User-Agent header as a part of HTTP aditional headers.
configuration.setUserAgentHTTPHeader()
// Initialize manager's properties.
URLSession.rx.shouldLogRequest = { _ in false }
self.session = .init(configuration: configuration, delegate: eventMonitor, delegateQueue: nil)
self.requestInterceptor = requestInterceptor
self.eventMonitor = eventMonitor
Expand Down Expand Up @@ -172,4 +173,17 @@ public class NetworkManager {
.retry(retryMaxAttempts, delay: retryPolicy, shouldRetry: shouldRetry)
return observable
}
/// Creates websocket object and establishes connection using provided url and protocols.
///
/// - Parameters:
/// - url: `URL` of websocket server.
/// - protocols: `[String]` websocket connection protocols.
/// - closeHandler: `WebSocketCloseHandler` used to provide close coda and reason upon connection closure.
///
/// - Returns: `WebSocket` object that represents the connection.
public func webSocket<T: Decodable>(_ url: URL, _ protocols: [String], _ closeHandler: WebSocketCloseHandler) -> WebSocket<T> {
let task = session.webSocketTask(with: url, protocols: protocols)
let webSocket = WebSocket<T>(task: task, closeHandler: closeHandler)
return webSocket
}
}
27 changes: 27 additions & 0 deletions Source/Web Socket/Extensions/Reactive+ping.swift
@@ -0,0 +1,27 @@
//
// Reactive+ping.swift
// RxNetworkKit
//
// Created by Loay Ashraf on 04/10/2023.
//

import Foundation
import RxSwift

extension Reactive where Base: URLSessionWebSocketTask {
/// Sends a ping to the websocket server.
///
/// - Returns: `Completable` observable encapsulating send ping operation.
func ping() -> Completable {
Completable.create { subscription in
base.sendPing { error in
guard let error = error else {
subscription(.completed)
return
}
subscription(.error(error))
}
return Disposables.create()
}
}
}

0 comments on commit 9e84cbb

Please sign in to comment.