I have android Game that uses AppWarp,
JFYI since the code base is quite complicated to share everything is very modular and distributed to multiple small classes so It might be better to describe the issue and how I debugged it.
First I'll describe what I'm doing there (Currently contains a lot of hacks even).
0-I have a nice debug log saying Main Activity of the app is created OnCreate(..).
1-I Instantiate AppWarp with key/secret.
2-Make sure the it's currently diconnected <-- Pure hack, normally shouldn't be like that.
2-Try to remove any listener (even 2 times). <-- Pure hack that normally should not be necessary.
3-Attach list of listeners Zone,Connection .... etc.
4-Connect AppWarp. and debug log just before asking for connect.
5-Debug log on every single method of the listeners. <-- Even the events that I never use (just in case).
6-When the user clicks start game ( I log debug this).
7-I search for old rooms that were not terminated properly, I first start search for room where the current user is "guestUser" (that's how I name it in the room properties).
8-I search for old rooms that were not terminated properly where the current use is "hostUser".
9-If I found any of the above (old rooms) and If I'm the host I terminate it, if I'm the guest, I don't do anything for now.
10-If I didn't find old rooms (usually the case): I search for rooms with at least and at most 1 user.
11-if (I didn't find rooms to join, then I create a room and join, and subscribe to it).
General note: for all the searching and finding / not finding logic I always use event-based call backs, i.e. if I search for rooms to join and the event is done and the result doesn't have rooms, then I move to creating a new room .... etc, I only ask to join a room once creation is done, I ask for subscribing only when joining is done ...... etc.
Now that's what I'm currently Getting with the happy scenario:
3-No old rooms found.
4-No rooms with 1 user found.
5-I create room
6-I join and subscribe to room.
8-14: User 2 from my other phone repeates the same steps exactly except that He finds room with 1 user and joins then game starts.
15-The game crashes on one phone
16-The game becomes paused on the other phone (the phone that didn't have a crash).
17-The game ends after the pause time ends (20 seconds in my case).
Now the trouble STARTS
1-I launch the app where the app crashed last time.
2-I instantiate the client.
3-I make sure its status is "Disconnected" i.e. Status 2.
4-I try to remove all the listeners that I never added since this launch.
5-I connect the client then I get connection done
6-I search for old rooms and find nothing.
7-I Search for rooms to join and find nothing.
8-I get a very random connection done event. <---- very suspicous.
9-I get another very random connection done. <----- very suspicous.
10-I choose to create room
11-I get room created done.
12-I get another room created done. <----- very suspicous.
13-I get a thirdt room created done. <----- very suspicous.
Each of these events try to do something to interact with UI, (The app crashes of course due to conflict of so many things).
14-I repeat the same bad scenario and I get more and more events triggered, as If the App Warp client is still persisting with so many events and listeners without any easy way to reset or clean it.
Now this is the scenario, My questions come next:
1-Is there any easy way to Completely and fully hard-reset the client without hacks (Reflection and accessing private properties) ?
2-Do you have open source version of the client ( i can decompile it but it's not the proper way to do things) ?
3-Are you persisting events / listeners or anything on disk or memory that doesn't terminate with the app?
How to reproduce:
1-Create a very simple Android app with 1 activity.
2-Create an external class that you'll use as a listener and implement the appropriate Listener Interfaces.
4-Add the external listener class that your created.
5-Connect to AppWarp, Create a room,
6-From another phone/app you need to join the same room.
7-Now in your app, force throwing an exception on click on one view or something.
8-Start the app again, and repeat the steps above, then inspect the WarpClient, and especially the list of listeners, you'll find it duplicated.
9-Crash the app again and repeat the steps above, and you'll find 3 listeners .... etc