DOCUMENTATION / UX NETWORKING

UX Networking

This system is used to manage communication between your app and your web-based API’s / backend servers.  We’ve started building out the UXLoginController for you as an example.  We’ve also created UXAPIController and UXReportingController as empty examples/quick starts.  Because UXNetworkingManager is a static instance, you can conveniently access any controllers that you instantiate through it from anywhere in the application.

UXNetworkingManager.cs

This is static class that can be conveniently accessed from anywhere in the application.  Recommended usage is to instantiate your API-specific controllers (ie UXLoginController for login functionality, UXAPIController for data API’s, etc) in this class and then use it as your access point to those public references.  Note that because UXReportingController is just an example, we’ve omitted it from the Properties & Functions section below.

Properties & Functions

string token

This is a public reference to the auth token that is set during login.  Note, you’ll need to set this in the TryLogin function in the UXLoginController.

UXLoginController loginController;

This is used for login and logout functionality.

Classes

UXAPIResponse

The UXAPIResponse is a convenience class that allows you to load a success bool, a string message (like the reason an API failed), and a generic dataObject Object into it for requesting classes to access.

UXLoginController.cs

Properties & Functions

IEnumerator TryLogin(string username, string password) => UXAPIResponse

Note: This is hard-coded to “success” and will require customization to function properly. Simply add your login API information and build your UXAPIResponse from the response data. This is a 4-step function.

  1. Call.  Use a Coroutine to call the function from your view’s script.
  2. Listen.  Subscribe to the onLoginResult delegate to listen for the response.
  3. Wait.  This is a great time to show a loading animation.
  4. Respond.  Handle the UXAPIResponse from the onLoginResult delegate, turn off your loading view, don’t forget to unsubscribe to the delegate, and then do your thang.

IEnumerator Logout()

Put your logout API code in this function and call it as a coroutine.

Delegates

onLoginResult(UXAPIResponse uxApiResponse)

Notifies listeners when TryLogin completes its API call.

onLogout()

Notifies listeners when Logout is called.

UXAPIController.cs

Properties & Functions

DownloadUserData()

This is a convenience function that is triggered when the UXLoginController announces a successful login.  This is function is part of a highly customizable template that is to simulate 1) getting data from the backend and 2) creating runtime instances of that data using the UXDataManager.

DownloadUserImage(UXUser user)

If the UXUser has an image link set in their data.profile_pic variable, this Coroutine downloads that image and then sets the data.userImage variable of the user.