/lib/titanium/mobile/network/BonjourBrowser.hx

http://github.com/visup/haxe-titanium-api · Haxe · 85 lines · 20 code · 8 blank · 57 comment · 0 complexity · 8730d5cb44f9c09ae43adb40049cea23 MD5 · raw file

  1. package titanium.mobile.network;
  2. import titanium.mobile.core.Dispatcher;
  3. /**
  4. BonjourBrowser class
  5. Documentation available at:
  6. http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Network-module
  7. - namespace
  8. Titanium.Network.BonjourBrowser
  9. - type
  10. object
  11. - description
  12. The BonjourBrowser instance returned from `Titanium.Network.createBonjourBrowser`. This object is a browser for the discovery and retrieval of Bonjour services available on the network.
  13. - since
  14. 1.2.0
  15. - platforms
  16. iphone, ipad
  17. - properties
  18. serviceType[string]: The type of the service the browser searches for
  19. domain[string]: The domain the browser is searching in
  20. isSearching[boolean]: Whether or not the browser is currently searching
  21. - methods
  22. search: Conduct a search for Bonjour services matching the type and domain specified during creation
  23. stopSearch: Halt an ongoing search
  24. - events
  25. updatedServices: Fired when the discovered services list is updated
  26. -event : updatedServices
  27. services: An array of BonjourService objects corresponding to currently available services. If you cache this value, including using it as table data, be aware that it could become out of date at any time due to the asynchronous nature of Bonjour service discovery.
  28. ~~~
  29. ~~~
  30. - notes
  31. If your application publishes Bonjour services itself, that service will be discovered by the browser if necessary; be prepared to perform a check if you do not want to list local services as available. Bonjour service browsing is an asynchronous operation, meaning that you should be extremely careful when caching values from the 'services' property returned by the updatedServices event. In particular, if you maintain a local copy of available services and a user tries to connect to one, you should be prepared to handle failures gracefully; the next updatedServices event should provide the new services list, but you should not rely on it being delivered before user input. When a window which uses Bonjour browsing is closed, if you do not want to continue searching, you must call the stop() method.
  32. **/
  33. #if iphoneos
  34. typedef NetworkBonjourBrowserUpdateEvent =
  35. { > Event,
  36. services:Array<BonjourService>
  37. }
  38. @:native("Titanium.Network.BonjourBrowser")
  39. extern class BonjourBrowser extends Dispatcher
  40. {
  41. // static constructor
  42. public inline static function create(serviceType:String, domain:String, ?params:Dynamic):BonjourBrowser
  43. return titanium.mobile.Network.createBonjourBrowser(serviceType, domain, params)
  44. // events
  45. public static inline var UPDATE_SERVICES_EVENT = "updatedServices";
  46. // properties
  47. public var serviceType:String;
  48. public var domain:String;
  49. public var isSearching:Bool;
  50. // methods
  51. public function search():Void;
  52. public function stopSearch():Void;
  53. }
  54. #end