GithubHelp home page GithubHelp logo

damonhu / ddpingtools Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 859 KB

iOS Ping tool, based on Apple's simplePing project

Home Page: https://ddceo.com/blog/1296.html

License: Other

Swift 77.44% Objective-C 21.14% Ruby 1.11% C 0.31%
ping pinger ios swift cocoapods

ddpingtools's Introduction

DDPingTools

This is an iOS platform for Ping tools, using swift language development. Support the use of cocoapods integration. It can be used in three steps

log iPhone X状态栏 statusBar 状态栏 statusBar
the ScreenShot 日志截图预览 the ScreenShot 状态栏 the ScreenShot 状态栏

introduce

Although the AFNetworking and alamofire provide the function of detecting the mobile network, they only know the user's network connection mode, but do not know the user's real user experience. Maybe the user is connected to WiFi, but the network speed is not as fast as 3G network.

So it encapsulates this function. You can ping the requested domain name through this project to get the return time and judge whether the user network is in the normal range.

The package is based on Apple's SimplePing and optimized again, which makes it easier to use and can be called in three steps

CocoaPods

pod 'DDPingTools'

1. Create a ping object with a hostname

let pingTools = DDPingTools(hostName: "www.apple.com")

2. Start Ping

pingTools.start(pingType: .any, interval: .second(10)) { (response, error) in
      print(response?.pingAddressIP ?? "")
 }

When interval is greater than 0, Ping requests will be sent repeatedly at fixed intervals. When interval is equal to 0, only one ping request will be sent

The response of the response contains the following contents

  • pingAddressIP is the IP address corresponding to the domain name
  • responseTime ping the response time
  • responseBytes Response bytes

3. Stop request

pingTools.stop()

4、Optional configuration

public var timeout: HDPingTimeInterval = .millisecond(1000)  //user defined timeout. The default value is 1000 ms. if it is set to 0, it will wait all the time
public var debugLog = true                                  //enable log output
public var stopWhenError = false                            //stop Ping when an error is encountered
public private(set) var isPing = false				//you can judge whether there is a ping task in progress
public var showNetworkActivityIndicator: NetworkActivityIndicatorStatus = .auto              //Whether to display in the status bar

Note: if the website or connected router is set to prohibit Ping, an error will be reported when pinging. You need to remove the restriction before you can use it normally

ddpingtools's People

Contributors

damonhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ddpingtools's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.