Created
January 30, 2012 01:02
-
-
Save benbahrenburg/1701720 to your computer and use it in GitHub Desktop.
Referencing the bencoding.network module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var benCodingNetwork = require('bencoding.network'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.API.info("Create a new Carrier Info Object"); | |
var carrierInfo = benCodingNetwork.createCarrierInfo(); | |
Ti.API.info("Get carrier name => " + carrierInfo.carrierName); | |
Ti.API.info("Get mobile country code => " + carrierInfo.mobileCountryCode); | |
Ti.API.info("Get mobile network code => " + carrierInfo.mobileNetworkCode); | |
Ti.API.info("Get ISO country code for cellular service provider => " + carrierInfo.isoCountryCode); | |
Ti.API.info("Mobile service provider supports VOIP => " + carrierInfo.allowsVOIP); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.API.info("Create a new Current Network Info Object"); | |
var currentNetwork = benCodingNetwork.createCurrentNetwork(); | |
Ti.API.info("Get SSID => " + currentNetwork.SSID); | |
Ti.API.info("Get BSSID => " + currentNetwork.BSSID); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.API.info("Create a new Reachability Object"); | |
var reachability = benCodingNetwork.createReachability(); | |
Ti.API.info("Get reachabilityWithHostName => " + reachability.reachabilityWithHostName("www.apple.com")); | |
Ti.API.info("Get reachabilityForLocalWiFi => " + reachability.reachabilityForLocalWiFi()); | |
var hostReachableByType = reachability.hostNameReachableBy("www.apple.com"); | |
function getReachableType(findType){ | |
var results = "Oops something went wrong"; | |
if(findType==reachability.NETWORK_STATUS_NOT_REACHABLE){ | |
results="Not Reachable"; | |
} | |
if(findType==reachability.NETWORK_STATUS_WIFI){ | |
results="WiFi Network"; | |
} | |
if(findType==reachability.NEWORK_STATUS_WWAN){ | |
results="Mobile Network"; | |
} | |
return results; | |
}; | |
var reachableType=getReachableType(hostReachableByType); | |
Ti.API.info("Reachable via => " + reachableType); |
same thing here. I recompiled it from the sources but the problem above is still there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Ben,
I tried to use function reachability.reachabilityWithHostName, but met below error, could you please advise?
Thank you very much.
Built with TiSDK 3.2.3.GA
[INFO] : Create a new Reachability Object
[ERROR] : Script Error {
[ERROR] : backtrace = "#0 () at file:///Users/zhoujun/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/2994286B-E7DD-49D8-8523-A9AB23CB560F/Test.app/alloy.js:231";
[ERROR] : line = 133;
[ERROR] : message = "invalid method (createReachability) passed to BencodingNetworkModule";
[ERROR] : sourceId = 361180448;
[ERROR] : sourceURL = "file:///Users/zhoujun/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/2994286B-E7DD-49D8-8523-A9AB23CB560F/Test.app/alloy/controllers/index.js";
[ERROR] : }
[WARN] : Attempted to load BencodingNetworkReachabilityProxy: Could not find class definition.