rpaschoal / ng-chat

💬 A simple facebook/linkedin lookalike chat module for Angular applications.
MIT License
155 stars 92 forks source link

Provide SignalR example for group chat #107

Closed rpaschoal closed 5 years ago

rpaschoal commented 5 years ago

I know this is not part of this issue, but please check this: https://stackoverflow.com/questions/54894884/cant-receive-messages-from-groups-ng-chat

Originally posted by @JosePolanco18 in https://github.com/rpaschoal/ng-chat/issues/105#issuecomment-472468011

rpaschoal commented 5 years ago

Some details on the issue for future reference as first replied on StackOverflow:

ng-chat treats groups as individual participants. You will have to join your room when this event gets invoked:

groupCreated(group: Group): void {
console.log( group);
// Invoke your SignalR hub and send the details of the newly created group
}

ng-chat will generate unique ids every time a group is created so you can track which group is which whenever one gets created from a running ng-chat instance. How you will handle the persistence of these groups is up to your application.

You might want to push a notification to involved users from your SignalR adapter that their friends list has changed (They'll be able to see the group at this stage). You could also decide not to do so and only push a notification if the user who has created the group send an initial message (Once again, up to your application requirements and needs).

You might also want to implement IChatGroupAdapter on your adapter to make the contract more explicit.

Hope this helps!

rpaschoal commented 5 years ago

I'll soon be adding support for group chat on the SignalR adapter example found here: https://github.com/rpaschoal/ng-chat-netcoreapp

rpaschoal commented 5 years ago

From my StackOverflow answer:

I've just pushed some changes on the "ng-chat-netcoreapp" repository. Have a look at the changes added with this pull request and look at the simple group chat example implementation I've added there: github.com/rpaschoal/ng-chat-netcoreapp/pull/1. Please note this is a quick implementation for a group chat adapter but it should be enough to get your head around the message and participants cycle. You should elaborate more on your code base for your adapter and hub to get production grade code in shape.

While testing I think I've found a minor bug with group messages not being marked as read. I'll do some more testing and confirm it is really a bug and push a patch anytime soon for it.

rpaschoal commented 5 years ago

The bug for unread messages not being marked as read for group chats has been released with version 2.0.2.