I am currently building a real-time messaging iOS application using React-Native and AWS-Appsync-GraphQL.
The basic architecture is when a user creates message on DynamoDB, the subscription triggers event function that renders the message to another users chat room.
The app has mutliple chat rooms and user shall reside in only one of them. Subscription is created when user enters the chat room and it become unsubscribed when the user leaves the room. And then new subscription is created then subscribed.
(Note that all subscriptions are specific to each chat room since I am using filtering argument for subscription.)
The most important feature to develop the app is how to manage the subscriptions. I need to keep subscribing/unsubscribing the subscriptions while prevents multiple subscriptions occurs. (I had observed that the app crashes when unsubscribed subscription stacked.)
Currently I had made a list and put the subscribed object into the list and unsubscribes it when user leaves the chat room then empty the list. Then put another subscribed object into it. This process happens in sequence by leveraging ("async", "then") method in javascript.
The problem is I don't know why but sometimes the unsubscribed subscriptions occurs/stacks and makes error in the app, such as multiple message rendering.
So I want to exhaustively list up the socket connection that made by AWS appsync graphql subscription operation and then unsubscribe those all so that I could 100% guarantee there's no redundant subscrption. (I am unsubscribing and not making any more subscription when app goes to the background)
How could I list up the every socket connection generated in the app?
I couldn't find any documentation about this since all the google search results are tagerted into the In-app-purchase related subscrptions.
- The app link is as following. Hope this link could be an hint to solve the problem. https://apple.co/2rD0RP9