Git Product home page Git Product logo

rareachability's Introduction

RAReachability

Yet another SystemConfiguration Reachability Wrapper.

What’s Inside

The project gives you RAReachabilityDetector which is a very lightweight abstraction around SCNetworkReachabilityRef provided by SystemConfiguration. You can monitor anything a SCNetworkReachabilityRef already monitors, and use Cocoa-style delegation to handle changes in network configuration.

If you just want to see if WiFi works, for example, do this:

self.wifiDetector = [RAReachabilityDetector newDetectorForLocalWiFi];

then implement the delegate method:

- (void) reachabilityDetectorDidUpdateState:(RAReachabilityDetector *)detector {

	if (detector == _wifiDetector) {
	
		BOOL wifiReachableDirectly = WASCNetworkReachableDirectly(detector.networkStateFlags);
		
		//	…
	
	}

}

You can invoke -initWithAddress: and pass a socket address, or -initWithURL: and pass an NSURL. Or, you can simply pass a SCNetworkReachabilityRef to -initWithReachabilityRef:, in all cases the class does the right thing and lets you know about the changes.

Since merely knowing if the networking layer works is only half the battle, there is also RAPulseCheckingReachabilityDetector. If you subclass it, and override -executePulseCheckingBlockWithCallback:, you have a chance to do additional work (networking, for example) and communicate with the application layer to see if it is suitable for processing more requests.

The class supports -compare: fully, so you can also hold several detectors in an NSArray, and sort them by availability.

Licensing

This project is in the public domain. You can use it and embed it in whatever application you sell, and you can use it for evil. However, it is appreciated if you provide attribution, by linking to the project page (https://github.com/evadne/RAReachability) from your application.

Credits

rareachability's People

Contributors

evadne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hsatac

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.