Skip to content

Instantly share code, notes, and snippets.

@alwx
Last active August 2, 2018 15:55
Show Gist options
  • Save alwx/a911408984791e0e9a80d1ac4302443c to your computer and use it in GitHub Desktop.
Save alwx/a911408984791e0e9a80d1ac4302443c to your computer and use it in GitHub Desktop.
status-dev-cli 2.0: Discovery process

Let's suppose the debug server is basically an HTTP server which runs on your device. It means that we can send almost any data between our dev machine and Status running on a device. In this case by "sending data" we of course mean "executing HTTP requests".

The only problem here is to detect a device itself (or, technically speaking, we need an IP of this HTTP server).

Option 1: no discovery

We can easily get the IP of the device on the device itself. This is how it works in AirDroid (old screenshot, but the idea is still the same): https://cdn.slidehunter.com/wp-content/uploads/Connect-AirDroid.png

As you may notice here, the device itself tells us its IP address.

Summary:

  • Easy;
  • No discovery means that there is no need in status-dev-cli — our application is becoming a web server and we can use curl or httpie or anything else to send requests to it;
  • Requires some UI: we need to display the IP somewhere in the app;
  • Maybe not that convenient as other options.

Option 2: use default tools to get this info

For Android:

For iOS:

Summary:

  • It requires adb and/or Xcode to be installed which is not always the case for DApp developers;
  • Developer mode should be enabled on your device;
  • However, it's quite reliable and doesn't require any additional tools (but you can say that XCode itself is an additional tool).

Option 3: Network discovery

We can use multicast DNS service discovery. Described here: https://github.com/agnat/node_mdns

The idea is quite simple — you can announce yourself in the network, and clients can search for you.

Summary:

  • Works and finds network services!
  • Can work even if device is not debuggable and if developer mode is not enabled;
  • Requires libavahi-compat-libdnssd-dev or Apple's mDNSResponder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment