Closed Nesbox314 closed 4 years ago
Hi @Nesbox314 ,
For onMessageReceived
, the first argument IChatParticipant
is who's sent this message to the receiving user. The second argument is not a string, it is of type Message
, and yes you should fill your Message
object.
Think of these adapter methods as "hookin up" your sockets implementation (Can be whatever you want, SignalR, Socket.io, etc) to the ng-chat component.
Let me know if this has helped. You can have a look at the .net core sample project or the nodejs one, here they are:
https://github.com/rpaschoal/ng-chat-netcoreapp https://github.com/rpaschoal/ng-chat-nodejs
Cheers!
Okay, thank you so much for the answer. Before I try anything else, I have one more question. In the first parameter of type IChatParticipant, do I have to fill the entire object?
I'll leave my code here. I've been doing a good search and in the configuration now, that's what happens. The code is in Portuguese, but I see that you came from Brazil, so it is likely that you do not have much trouble understanding. I'm using SockJS with an API in Spring.
Here's an example of how chat is reacting now.
Send example:
Receiver example:
Notice that, I send the message to "Fabiane", and in the other window, that I am logged in with "Fabiane", instead of opening a user window "Ricardo", which is the user that sent, opens a window by Fabiane.
Aqui vai o meu código.
Please help!
Hi @Nesbox314 ,
Just checking out if this is still an issue for you? Reading your code above it seems you have to swap the fromId
and toId
message properties.
So, I'm trying to use this method to receive the messages, however, strange things have been happening, one of them is: I send the message, and when the socket returns the object, a window opens in the destination (correct) another on the shipping tab. I'm pretty lost in that regard. But my final question is, what are the features that I have to go through in the onMessageReceived method.
Here we have the method:
onMessageReceived (participant: IChatParticipant, message: Message): void;
Exact, but what should be passed in the first parameter? The sending participant or the destination participant? Who knows even both?
In the second parameter we just pass the message in a string? Do we send the entire body of the message with all the attributes? Even with "toId" and "fromId"?
Thanks.
Some example of what is happening.
Send tab:![envio](https://user-images.githubusercontent.com/46055626/56239781-43b03f00-6068-11e9-9ebb-72164e7a6dbb.PNG)
Destiny tab![destino](https://user-images.githubusercontent.com/46055626/56239840-63476780-6068-11e9-9702-ec0359b01a31.PNG)
Please help!