Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Relating Users in Parse.com Storing Friend Relationships

Expanding on the idea of ParseRelations...

I was able to follow along and understand what was being done. So, I tried to apply it to a different model and just got... lost.

Ok, say I have user1 and user2. I also have chatRoomA and ChatRoomB. My thoughts are along this line:

user1 enters chatRoomA. user2 is already in chatRoomA. User2 already has a list of messages on his screen. When user1 enters, he receives the last 20 posts to his screen. When either one of them posts, the other's screen should update with the post. Now, I'm only using two ppl, but each room can have 100s of people in it.

Here's where I get confused. if a user can be in only one room at a time, is that a one-to-one? if a room can have many users, is that a one-to-many?

I'm trying to follow the documentation. When a user enters a room. I would do something like: ParseObject chatroom = new ParseObject("chatroom"); chatroom.put("activeuser", ParseUser.getCurrentUser());

When a user makes a post, he'd have to query for all active users in the chatroom. Would the relation then be added to both chatroom and the list of active users?

I'm confused on where to set the relations. well according to the documentation, as I understand it, pointers would be the best solution for this. Any insight would be greatly helpful.

Maybe it would be better to say something like I would like to create a chat app where I can have different "rooms" and "sub-rooms" for example: Dating:M4W

Where Dating is the main room and M4W is the sub-room.

After going through this project, I became extremely interested in Parse and figured a chat program would be a nice challenge, but figuring out the associations have proven to be challenging, not to mention I'm not even sure if I should use Parse's Push service. I'm thinking if I don't use the Push service then I'd have to poll the server every 5 secs or so for new posts since it's not being pushed.... hrm, I guess that would also mean that any new rooms created would only show when OnResume is triggered, right? Lots to think about, again any suggestions would be very helpful.

1 Answer

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

This is a pretty significant undertaking, but it will be worthwhile if you get it all working! Sounds like a great learning experience. If you stick with Parse, you could try handling push notifications with an intent like I just mentioned in your other post. I googled "android real-time chat parse" and found some other potential solutions you could try that involve tying into other services, too.