0

I'm developing an android game using xamarin.android. Backend logic of game is hosted on smartfox server and I'm using smartfox Unity client API to consume the services.

My project architecture is: Xamarin.android -> PCL (portal class library).

Smartfox server client API is implemented within the PCL. Smartfox server keep triggering callback methods from backend and we have to capture those callback events and modify UI basis on that.

Now I'm unable to implement an architecture which can capture these callbacks and send it to UI. I'm able to capture callback within PCL but don't have any idea how to forward these to UI.

Please help me out with an architecture that can fit into this particular scenario. I tried to implement triggers but don't know how to access a UI method in PCL.

theB
  • 6,450
  • 1
  • 28
  • 38

1 Answers1

0

You don't access UI in a PCL. PCL's are platform agnostic, so you really can't do that there.

I can think of a couple of ways to pass the data on to some UI or something controlling the UI.

  1. Your API client could implement some Events which the UI or controller is listening to, and in here handle the event.
  2. You could implement a MVVM pattern and through a messenger or a View Service notify the ViewModel about callbacks and manipulate the ViewModel accordingly, which then reflects in the UI.
Cheesebaron
  • 24,131
  • 15
  • 66
  • 118