-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to init a group discussion? #44
Comments
Ok so I was trying 👍
And I see this in the source code for .createThread:
If the thread doesn't exist yet and I am click since I am the only "user" at the time viewing the thread it will always create a new one. Why are you checking for "two users" ? |
Imagine a user User A is chatting to User B. Now User B exists the thread and creates a new thread and adds User A. In this situation we would have two threads between User A and User B which doesn't make sense. In this case, the app will just return the existing thread rather than creating a new one. This is only the case with 1-to-1 threads because group threads are naturally flexible and it would make sense to have two different group threads even if they had the same users - maybe about different topics. |
ok, right. So..... how do I create a group thread? What is the syntax? I swear I looked all around the code (which is a good thing). I need to have open topic chats that don't go away. Thanks |
You just need to pass in more than two users. |
Just to extend: You can see below that you are creating a thread with only a single other user. You can use an array with more users to create a group chat: [userA, userB, userC].
You can also see the duplicate code logic in the BFirebaseCoreHandler.m:
You can see the logic of checking whether this thread already exists. This would be the code to modify if you wanted to change the functionality regarding this. Simon |
In my use case, I want to have say lobbies. A lobby needs to be created and not destroyed no matter how many "users" are currently in that lobby chatting. The question becomes, how do I bootstrap the lobby? It would seem I need a method to create a chat group with a specific unique string code. What happens in your code then if it is an empty lobby at the moment and a user wants to chat? My other chat had: FIRDatabase.database().reference().child("channels/INDX420") which allowed easy chat group creation. Maybe another method like: Would this cause other downstream problems? |
Actually this functionality would be better provided using the public chat type. Public chats are like lobbies - when a user joins, they are added to the room's user list. When they leave, they are removed from the list.
There are a number of ways to create these rooms initially, you could just hard code it into the app so if the public room doesn't already exist, the app tries to create it. Or you could just replicate this code:
You can explicitly set the thread's entity id before you push it. This approach has the added benefit that the thread would never be added to the public threads list so it would essentially be a hidden public chat room. You could provide the list of lobby IDs from a server API or a config file accessed by the app. |
I could use a Swift Version as I am not familiar with RXPromise.
How does a promise get turned to a Thread? Anyway, my confusion also lies in the concept of the entityID. Where is that being set? It wasn't obvious to me perusing the code. Also do I first need to check for this thread.entityID before I create? Thanks |
I added a new function to the codebase so your code would look like this:
There is also a function that converts an |
Yes! Thank you. |
Hello -
Have chat working and exploring. Now I need to have a group chat discussion. Basically I want to make a chat room for each of my brands. How do I pop open a chat with the group already initialized say with the brand code?
Thanks
The text was updated successfully, but these errors were encountered: