Azure / Azure/DotNetty

how to group Channel ?

Open
#432 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.3k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Hi, i'm wondering if there is any way to create IChannelGroup ?
to sum up what i'm trying to achieve i would like to have many "room" where i can send a message so something like this.
```
public class Room {
public IChannelGroup RoomUsers;
}

var Room1 = new Room();
var Room2 = new Room();
Room1.RoomUsers.Add(someone);
Room1.RoomUsers.WriteAndFlushAsync("1");
Room1.RoomUsers.Remove(someone);
Room1.RoomUsers.WriteAndFlushAsync("2");
Room2.RoomUsers.Remove(someone);
Room2.RoomUsers.WriteAndFlushAsync("3");
```

in this example i'm expecting someone to receive:
```
1
3
```

for the moment i'm using a workarround where i put my IChannel inside a ConcurrentDictionary and iterate on it to WriteAndFlushAsync but i'm feeling like there may be a better way with the IChannelGroup. Unfortunately new DefaultChannelGroup(contex.Executor); need a parameter which i have no idea on how to retrieve it in another scope than a channelHandler

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.