Hello There!
I want to know if it is possible to make a code that identifies if a device is online i.e it is connected to the cloud service because there's no way I know to run a script when someone leaves the game. Or is there some script I can run when the user turns the device off or exits the app?
There is no built-in code or Method to monitor the participation in a CloudDB link Mayank. A user is possibly in the 'game' when he/she responds to an activity but there is no way to tell if the user got bored and left or lost his Internet.
What is possible using the MIT CloudDB control is documented here> * CloudDB
The CloudConnected method identifies if the app connected to the CloudDB has a connection
CloudConnected()
Returns true
if we are on the network and will likely be able to connect to the CloudDB
server.
If that person's app uses a Clock to continual poll that method, the method can be used to determine if he/she no longer connected. It does report to the other users the individual left the chat.
To monitor the status of all 'chat' members, write code to determine their status. How? Be creative. Perhaps have all users Beacon the database with an 'I am here message' to the database using a Clock. Use the DataChanged block to provide the status of the members 'online' and report that information on all the users screens who are currently active. That might work. Does it?
You probably can write the code to be able to do some monitoring of activity using the Methods and Events in the CloudDB control -at least you could determine if the user is currently active and monitoring. You might be able to use
CloudDBError( message )
Indicates that an error occurred while communicating with the CloudDB Redis server.
with other tools. However, if the person turns off his device, he/she certainly cannot message.
Hmmm...
You are right, I can do that. Whenever the user is in the game, I will use When Clock1.timer
to delete and reapply the value of a tag and then set a variable to false. After the a change is detected using When Firebase/CloudDB.dataChanged
I will test if (Var == false && Value == MyId) then{I AM ONLINE}
after the device has read the value and has confirmed it is the player itself, the variable will be back to true. if the variable is not set to true in time then, the person will be considered disconnected and everyone will receive message. Am I Right?
The only way to know is to try. In theory, that process might work.
This is a real time database. The concept may work with a few users but not work well with many users. There will be multiple users sending status data so expect the DataChanged to have to handle a lot of data. How many users can your Redis server and the DataChanged event handle without creating data collisions? I don't think anyone knows what happens with heavy usage. My experience is some things work with a few users but the same coding might have problems when more than several users are active.
Don't assume what works when a single user is active will work with multiple users. Create a Project to test the ability to detect who is 'on line'. Test your Blocks and let us know.
The usage will not be as heavy as you expect it to be. I said I will be deleting the values as soon as they are read, so that the server will not be under high pressure.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.