I have create a chat with just 1 room, private messages, moderation and everything now and it all works great! While I was testing the chat, I realised that all the messages every typed in the chat got saved and if you had a lot of people using the chat it would very quickly take up quite a lot of space in your Firebase.
To give you an example of what I am looking for, let me show you how I handle private messages:
When John sends a private message to Bob, the message will be added to both John and Bobs list of private messages, like this:
/private/John <-- Message appended here
/private/Bob <-- Message appended here
This is an example of how the firebase would look with 2 message in the chat, and 2 private messages:
{
"chat" : {
"516993ddeea4f" : {
"string" : "Some message here",
"time" : "Sat 13th - 18:20:29",
"username" : "test",
},
"516993e241d1c" : {
"string" : "another message here",
"time" : "Sat 13th - 18:20:34",
"username" : "Test2",
}
},
"private" : {
"test" : {
"516993f1dff57" : {
"string" : "Test PM reply!",
"time" : "Sat 13th - 18:20:49",
"username" : "Test2",
},
"516993eb4ec59" : {
"string" : "Test private message!",
"time" : "Sat 13th - 18:20:43",
"username" : "test",
}
},
"Test2" : {
"516993f26dbe4" : {
"string" : "Test PM reply!",
"time" : "Sat 13th - 18:20:50",
"username" : "Test2",
},
"516993eab8a55" : {
"string" : "Test private message!",
"time" : "Sat 13th - 18:20:42",
"username" : "test",
}
}
}
}
and the same goes the other way around. Now if Bob where to disconnect, Bobs list of private messages get removed, but John is still able to see his conversation with Bob because he got a copy of all the messages on his list. If John then disconnect after Bob, the Firebase would be cleaned and their conversation no longer stored.
Is there a way to achieve something like this with the General chat? Pushing a message to all the users who are using the chat does not seem like a good solution (?). Or is it possible to somehow make the Firebase only keep the latest 100 messages for example?
I hope it makes sense!
Kind regards
Ps. Big thanks for the Firebase team for all the help so far, I really appreciate it.