I'm building a chat system, each application instance will represent a channel. For instance:
In the on onAppStart handler I need to query a database to see if the channel name (instance name) exists and also get the config for the channel. If the channel doesn't exist in the database, or there was an issue with the query I need to close the application instance.
I've tried calling appInstance.getApplication().shutdownAppInstance(appInstance.getName()); in the onAppStart handler and clients can still connect to the chat instance.
I've also tried calling client.rejectConnection(); and appInstance.getApplication().shutdownAppInstance(appInstance.getName()); in the onConnect handler and it seems to work. Is this the best approach? Or is there a better way?