CloudDB question

I am developing an app that uses CloudDB and came across something interesting that I wanted to discuss.

This is a multi-user app .. more than one person will be using the app at a time. Parts of the app share the same database with all of the users. When I say database I mean all the users share the data that is under the same tag. That part works fine. If I add data, everyone sees it as designed.

The issue I came across is when a user, anyone, changes tags to a different tag it takes the rest of the users with him to the new tag. Not expected.

I can be the only user in the app, change to another tag and that works fine. If another user signs on to the app while I am in a different tag everything works as designed. I can add my data in my tag and he can add his data under his tag with no conflicts. But as soon as anyone changes tags it takes all the users with him and we are all under the same tag. I don't understand how this is happening.

At first I thought this was a limitation of CloudDB so I made a version using FirebaseDB and the same thing happened over there. This makes me think its my code since its really the only thing in common.

Has anyone else seen this behavior before? Let me guess, you want blocks.. there are a lot and I am trying to figure out the best way to present them with the least amount of headache but I will post them ..

what's this means?

I do not know how else to describe .. exactly what I am saying. If anyone changes tags and goes to a different 'database'' .. a different tag.. everyone that is logged in goes with them.

still don't understand

Can you confirm this is with a compiled app, and tested on different devices with different user names.

Yes. I have confirmed on different devices, compiled the app, different usernames. This is how I know that it is happening.

This is a chat room app. When everyone is in the 'main chat room' it works. If someone changes to a different chat room (changes tags) it takes everyone with them to the new room. Strange.

If I am in a different room by myself and then someone logs into the app (main chat room) it works fine. I can chat in my room (granted by myself in this example) and they can in the main chat. Everybody is happy. But when someone in any room changes rooms.. we all end up in the new room. I dont understand why. All the other variables in the app are unique to the user and their device, but the room tags are shared between us somehow.

Here are the blocks for changing rooms. I use CHANNEL as the tag for the room that the user is in.

Difficult to tell from the blocks, but it looks like you are setting Channel as the tag in a list which will then set everyone's channel to the same chatroom. You should setup your blocks and tags per user, not globally.

1 Like

But am I not doing that already? I mean, the user is the one using these blocks.. these are his blocks.. I guess I am not sure what you mean?

I dont understand why the blocks are setting everyones rooms universally .. obviously its happening.. but why are not all the other variables being changed then too? Usernames.. etc..

I dont believe that I am using the tag CHANNEL as a list. Its just a variable for the room that the user is in.

Pardon me for the simplistic example, but are you saying I should use 'green' blocks instead of 'orange' blocks for the channel? The local blocks instead of the global ones?

green blocks, I do not believe so. I am guessing that somewhere in your chatroom selection logic that you are setting a global (for all users) that takes them to the same chatroom. Work through your logic....

I agree.. it IS a logic issue. I am looking, and have looked. Its probably right there in front of me but I dont recognize it.

This isnt the first time this has happened to me.. but if I stare at it long enough I do eventually see it. I was just hoping that someone can rattle my brain enough to make me think at it a different way than I am now.

But to confirm.. this is not a CloudDB limitation, and what I am trying to do IS possible, yes?

Yes, of course :slight_smile:

New developments.. I did a little troubleshooting and I discovered that it app is not changing rooms for everyone .. they are still where they were. Its the ListView data that is changing for everyone. Its basically the same thing but the room changing routine works as designed.

What I need to do is make sure that the room name (the tag) is still the same in ListView somehow.. at least that's what I am going to try next.. I should not need to have a separate ListView for each room, should I? Isnt that what Tags are for?

Again, it appears that your app is setting the listview data globally for all app users, not for individual users. Fix that in your blocks.

Im thinking it through.. I will get there..

Is there an example anywhere of setting the ListView data for individual users? I cannot figure this out..

Think about it this way:

CloudDB: data
App: user

Let me ask these two questions..

The event blocks ClouDB.GotValue and CloudDB.DataChanged .. does the DataChanged event fire when ever data changes for ANY tag or only the current one that I am using?

And I am not sure how the GotValue event blocks works at all .. when I hover over it, all it tells me is "indicates that a" .. those three words are not very helpful at all.

I am thinking that these blocks have something to do with my issue.

I appreciate the ideas, I really do. I want to figure this out. I guess I am just on the wrong track.

As I see it, and please correct me if I am wrong, CloudDB is a list of lists. Each list is defined by the Tag (the name of the room the user is in) and each of those lists is made up of the ListView elements.. those are the individual messages. The user chooses the tag and should only see the messages available for that particular room. I dont understand how the data is global instead of individual, to me it already is?

  • The dataChanged event will fire whenever any tag value is changed.
  • GotValue does just that, when you request a tag with GetValue, GotValue will return the value for that tag.
  • CloudDB is a key:value (tag:value) database. You can store a single value to the key, or you can store a list to the key, which is returned (with GotValue) as an AI2 list.