Example App

Use the example application to understand the interactions between application, microservice, and edgeSDK.


Prerequisites


All Platforms

  • Git v2.0.0+
  • A mimik's Developer's Account (If you have not yet registered one, you can follow this instruction to get one)

Specific Platform

Platforms:Requirement:
Android
  • Android Device running Android v5.0.0+ and connected to internet.
  • Android Studio v3.0.0+
  • A PC with either Linux, macOS or Windows OS.
iOS
  • Apple Device running iOS v11.0.0+ and connected to internet.
  • Xcode v10.0.0+
  • Swift v4.0.0+
  • A Mac running macOS
Linux
Windows
macOS


Installation


Android :

1. First download and install the edgeSDK Service for Android on to an Android mobile device.

2. On your development machine uses the command line to clone the edgeSDK project from GitHub to somewhere that is accessible to you. This guide starts from the default Downloads folder for Linux:

Note: For Windows user, please download Cygwin or Git Bash to perform this.

cd ~/Downloads
git clone https://github.com/mimikgit/edgeSDK.git

3. Open Android Studio, select open an existing project and find the example app repository on your local machine.

4. Run the build on a physical android device.


iOS :

1. On your development machine uses the command line to clone the edgeSDK project from GitHub to somewhere that is accessible to you. This guide starts from the default Downloads folder for macOS:

cd ~/Downloads
git clone https://github.com/mimikgit/edgeSDK.git

2. Navigate to the example iOS directory

cd /examples/iOS\ Hello\ App/

3. Install the required cocoapods

pod install

4. Start Xcode and open the example app project.

Attention: You must use a real device, not emulator to build the example app. edgeSDK will not operate on the emulator devices.


Linux , Windows and macOS :

1. On your development machine uses the command line to clone the edgeSDK project from GitHub to somewhere that is accessible to you. For Linux or macOS user, feel free to use built-in terminal to perform following commands. For Windows user, please use Git Bash.

git clone https://github.com/mimikgit/edgeSDK.git

2. Navigate to the folder where the example app resides and redirect to:

cd example/PC\ Hello\ App/

3. Install the node dependencies by running the following command: it may take a few minutes to complete

npm install

4. Now, we need to start edgeSDK. Please go check the following guides to learn how to start and install edgeSDK:

5. Follow the microservice deploy and build guide to build an example microservice under the /example/microservice and verify that the container image has been created. Once verified, the PC example app is able to detect this default installation path without needing to modify the source code. To check that, see if example-v1.tar file is under the directory:

ls ~/Downloads/edgeSDK/example/microservice/deploy

Optional: You can also open the src/hello_world/hello_world.js file in PC Hello App directory and hard code the path of microservice to the folder containing the example-v1.tar file in the addImage function by assigning the path to the containersPath variable.

6. Now, after you have obtained your developer's account and added an application's OAuth detail to developer's portal. We have to do some modifications on the src/background.js file using the App-ID and Redirect URI that provided by you for your app in the mimik's Developer Portal. Find the following variables on the file and modify them:

Note: If you haven't done setting up the Developer Portal, you can go to this page and follow the instruction on the page to accomplish this.


                                      const APP_ID

                                      const REDIRECT_PROTOCOL
                                      
                                      const REDIRECT_URI
                                  

7. Enter the following command to build the example app in a development environment:

npm start

8. To package the app for your specific OS run the following command:

npm run package

9. To test and package run the following command:

npm run release

10. The above two commands would produce one of the following installation files in the dist folder based on the OS that source is hosted on:

  • For Linux: mimik-sample-app--x86_64.AppImage
  • For Windows: mimik Sample App Setup .exe
  • For macOS: mimik Sample App--mac.dmg

11. Now just double click on the executable file listed above to install the app and play with it.

Note: You might need to right click the AppImage file for Linux to change its permission to run as executable file.


Using the App

Once the application is running on your test device, there are a few functions that you can test out:

  1. First start the edgeSDK service.

  2. Next, go to the newly installed example app and press the login button. Use your Developer Account credentials to login.

  3. Allow the example application to access your info through the OAuth authorization.

  4. The app will show feedback that the edgeSDK acquired your user token and you continue associate edgeSDK to your account.

  5. Press dock to deploy the example microservice. Once deployed, you can discover other local devices with edgeSDK nearby.

  6. Tap on any devices to see a hello world response at the bottom of your screen.


App Flow

Below is the flow of account authentication and authorization in example app:

app registration

  1. First, the example app associates edgeSDK with accountID. Account association in app is done through JSONRPC calls.
  2. Developer registers example app to mimik developer portal and receives the account information and account key as seen from HERE.
  3. In the sample app, it uses registered account key to associate example app with edgeSDK. That's done through associateAccount(edgeToken).
  4. App verifies that edgeSDK associated with the correct account info through making another JSONRPC calls to getMe().

After the authentication, the flow of messaging looks like this through two edge-cloud clustering methods:

account cluster

  1. Account Clustering: App makes request through example microservice to retrieve account cluster nodes from the mimik's back-end service.
  2. mPO requests the nodes information including BEP references of account cluster nodes.
  3. mDS gets the account key and returns cluster nodes information.
  4. mPO returns nodes and profile information of cluster account.
  5. LinkLocal Clustering: App requests nearby devices through microservice on edgeSDK.
  6. If available, example microservice uses the local IP of account cluster nodes to communicate with them.
  7. Example microservice return account cluster nodes ( through BEP or local IP) and then sample example displays info on the app screen.
  8. User selects one of the nodes, then app calls hello API on microservice with select nodes' url to get a message from this node.
  9. Show the hello world response.