I am using Strophe.js to connect with XMPP server in angular6. connection.addHandler()
is method to receive messages.
My component structure is
Parent Component:
which contains users list with whom I chat and latest message below user name, which is at left side of page.
e.g.
user1
Hi...
Child Component: In right side there are chat messages with particular user, like two way chat window.
Refer enclosed images for structure.
When I receive message from user1, it appears in left side i.e. below user1 name ('Hi' will be replaced with new latest message)
This is handled with connection.addHandler()
call for left side/parent component.
This code should also be automatically executed for child component. So that new latest message should appear in chat list, but that is not happening.
Here is the listener code:
`connectionXmpp.connection.addHandler((msg) => {
console.log(msg)
return true;
}, null, 'message')`
I have added connection.addHandler()
listener in parent as well as in child component, also tried only in parent component by using if else conditions
, but in vain.
Please let me know, where I did wrong or have any solution to call listener in both parent and child component.