Hi,
I'd be really thankful if you review following architecture and let me know how to run each channel in one thread and which thread is proper for this:
I'm developing a chat application in which there are many rooms (referred to channel in code).
Code:
public class ChannelEngine : IChannelEngine
{
....
public bool AddChannel(string channelname)
{//is called, through server.aspx, for creating each room
lock( syncRoot )
if( !ChannelExists( channelname ) )
{
if (Channels.Count >= Global.MaxRoomNum)
{
return false;
}
// Create Chat Engine for new channel
ChatEngine.ChatEngine channel =
new ChatEngine.ChatEngine();
Channels.Add( channelname, channel);
}
return true;
}
}
public class ChatEngine : IChatEngine
{
//this class contains a few functions that are called from client code every other second
}
The problem is that when users are in the same room they can chat without any problem but when one user switches to another room, the users in previous room cannot send/rec. text because those functions in ChatEngine are run completely only for the new room! I thought putting each room in one thread could help but I don't know how?