Created live chat with sockets as to Teodors tutorial, this works, except sometimes the message is emitted twice.
Any ideas why?
My application requires the ability for members who are part of separate ‘partnerships’ to communicate only with members with the same partnership_id.
This would require separate rooms to be created which could be named using the partner_id
I have added the parameter ‘partner_id’ to the chat_message socket but don’t know how the client joins the room associated with his associated partner_id.
To look at why messages are sent twice we would need to see some code.
As for the partnerships, are they separate chat rooms where everyone talks to everyone else in the partnership (like WhatsApp groups) or is it for direct chats but only to other members of the same partnership?
And are you trying to find the best way for a member to add themselves to a partnership or would this be done by an admin?
Ok, so I assume you have recorded somewhere else in your database which users are in which partnerships?
In that case in Teodors tutorial (I am assuming it is this one), where the chat originator selects a user on the client side, restrict that list to just users who are in the same partnership by using the partnership_id in the source query.
If it is a message to multiple users and you have a list of partnerships the chat originator is a member of then use the selected partnership_id to restrict the message to only other members of that partnership.
If not the automated logic to enrol a user in a partnership is separate to the chat process.
that is the crux of my problem, I don't know how to filter the contents of the local storage which contains the partnership_id, I have tried using dataview with the filter 'partnership_id==x' but referencing the dataview from the repeat doesn't seem to work??
Thankyou @paulBS@bpj
the code was good but I had to create a new repeat (with the expression I showed above) and it now works.
I have noticed before there seems to be some corruption in the code sometimes when the query/expression is edited and the only solution seems to be deleting and starting again.