{"id":18426115,"url":"https://github.com/clevertap/ctsimpleping","last_synced_at":"2025-07-10T10:39:32.572Z","repository":{"id":145639502,"uuid":"469183147","full_name":"CleverTap/CTSimplePing","owner":"CleverTap","description":"A basic wrapper around iOS Simple Ping","archived":false,"fork":false,"pushed_at":"2024-10-30T10:25:41.000Z","size":963,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-02-16T08:25:27.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CleverTap.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-12T19:40:48.000Z","updated_at":"2025-01-13T11:35:51.000Z","dependencies_parsed_at":"2024-12-24T19:52:36.977Z","dependency_job_id":null,"html_url":"https://github.com/CleverTap/CTSimplePing","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleverTap%2FCTSimplePing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleverTap%2FCTSimplePing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleverTap%2FCTSimplePing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleverTap%2FCTSimplePing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CleverTap","download_url":"https://codeload.github.com/CleverTap/CTSimplePing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766184,"owners_count":21158297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T05:06:57.050Z","updated_at":"2025-04-13T18:53:44.014Z","avatar_url":"https://github.com/CleverTap.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CTSimplePing\nA basic wrapper around [iOS Simple Ping](https://developer.apple.com/library/archive/samplecode/SimplePing/Introduction/Intro.html)\n\n## Example Usaage\n\n    import Foundation\n    import CTSimplePing\n\n    public typealias SimplePingClientCallback = (String?)-\u003e()\n\n    public class SimplePingClient: NSObject {\n        static let singletonPC = SimplePingClient()\n    \n        private var resultCallback: SimplePingClientCallback?\n        private var pingClient: CTSimplePingClient?\n        private var dateReference: NSDate?\n    \n        public static func pingHostname(hostname: String, andResultCallback callback: SimplePingClientCallback?) {\n            singletonPC.pingHostname(hostname: hostname, andResultCallback: callback)\n        }\n    \n        public func pingHostname(hostname: String, andResultCallback callback: SimplePingClientCallback?) {\n            resultCallback = callback\n            pingClient = CTSimplePingClient(hostName: hostname)\n            pingClient?.delegate = self\n            pingClient?.start()\n        }\n    }\n\n    extension SimplePingClient: CTSimplePingDelegate {\n    \n        public func simplePing(_ pinger: CTSimplePingClient, didStartWithAddress address: Data) {\n            pinger.sendPing(with: nil)\n        }\n    \n        public func simplePing(_ pinger: CTSimplePingClient, didFailWithError error: Error) {\n            resultCallback?(nil)\n        }\n    \n        public func simplePing(pinger: CTSimplePingClient!, didSendPacket packet: NSData!) {\n            dateReference = NSDate()\n        }\n    \n        public func simplePing(pinger: CTSimplePingClient!, didFailToSendPacket packet: NSData!, error: NSError!) {\n            pinger.stop()\n            resultCallback?(nil)\n        }\n    \n        public func simplePing(_ pinger: CTSimplePingClient, didReceiveUnexpectedPacket packet: Data) {\n            pinger.stop()\n            resultCallback?(nil)\n        }\n        \n        public func simplePing(_ pinger: CTSimplePingClient, didReceivePingResponsePacket packet: Data, sequenceNumber: UInt16) {\n            pinger.stop()\n        \n            guard let dateReference = dateReference else { return }\n        \n            //timeIntervalSinceDate returns seconds, so we convert to milis\n            let latency = NSDate().timeIntervalSince(dateReference as Date) * 1000\n            resultCallback?(String(format: \"%.f\", latency))\n        }\n    \n        public func simplePing(_ pinger: CTSimplePingClient, didSendPacket packet: Data, sequenceNumber: UInt16) {\n             dateReference = NSDate()\n        }\n    \n        public func simplePing(_ pinger: CTSimplePingClient, didFailToSendPacket packet: Data, sequenceNumber: UInt16, error: Error) {\n             pinger.stop()\n             resultCallback?(nil)\n        }\n    \n        public func simplePing(pinger: CTSimplePingClient!, didReceivePingResponsePacket packet: NSData!) {\n            pinger.stop()\n        \n            guard let dateReference = dateReference else { return }\n        \n            //timeIntervalSinceDate returns seconds, so we convert to milis\n            let latency = NSDate().timeIntervalSince(dateReference as Date) * 1000\n            resultCallback?(String(format: \"%.f\", latency))\n         }\n    }\n\n\n## Install\n\n### [Swift Package Manager](https://swift.org/package-manager/) \n\nAdd the `https://github.com/CleverTap/CTSimplePing.git` url to your project's Swift packages\n\n### [CocoaPods](https://cocoapods.org)\n\n```\n target 'YOUR_TARGET_NAME' do  \n      pod 'CTSimplePing'  \n  end \n```\n\n### Manual\n\nDownload the `CTSimplePing.xcframework` included in this repository, drag it into your project and add it as an embedded framework in your build settings\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclevertap%2Fctsimpleping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclevertap%2Fctsimpleping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclevertap%2Fctsimpleping/lists"}