Asynchronous Voice App Question


#1

Let’s say I am making an Alexa skill which is intend to be used by multiple people at once. Do I need to make the Voice APP code asynchronous? For example, I have a DBManager class, which allows connections and queries to be made. This class is used in my app.js file. Normally, I would make these methods asynchronous, so multiple people using the app could connect and query at the same time. However, I am wondering if there is anything built into the Jovo frameworks which handles this? Any insights would be helpful! Thank you in advance!


#2

My assumption is that Jovo handles multiple users and if I instantiate the DBManager class inside the app.js file in an intent handler, then each user will have their own instance of the DBManager class, everything will be groovey. There will be no need for async methods in DBManager.


#3

Hey Amir!

The abstracted DB class handles multiple users.

Which DB do you want to use?


#4

Just a relational database on a dev server at my work. What abstracted DB class are you referring to?


#5

I have made my own DBManager which connects and makes queries to a db I have hard coded into the class.

Right now, the connect and query methods are asynchronous.

It appears to me that the voice app I have made, built on Jovo’s framework, can handle multiple users concurrently.

I have a instance of my DBManager class used in the voice app when a certain intent is detected. It would seem to me that each user will end up with their own instance of the class, i.e., a connection. Which, to me, implies that there is no need for any asynchronous methods in my DBManager class.

Am I just not understanding how the framework operates? Am I being clear?


#6

Hi @Amir_Ansari,

I don’t think you would need asynchronous code. @AlexSwe correct me if I’m wrong, but you can think of the Jovo App as a web server. When you start it, you create an instance of the app. This instance listens on a specific port for incoming client requests. Once a new request has been registered, the app opens a new socket and handles the request. Each request opens a new socket, so if you instantiate a new DBManager in an intent, each new user gets an own DBManager.