Skip to content

Instantly share code, notes, and snippets.

@ssukhpinder
Created June 5, 2021 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssukhpinder/3b1f3b0280b59c196336562f0432b724 to your computer and use it in GitHub Desktop.
Save ssukhpinder/3b1f3b0280b59c196336562f0432b724 to your computer and use it in GitHub Desktop.
public class Chatroom : AChatroom
{
private Dictionary<string, User> _users = new Dictionary<string, User>();
public override void Post(string fromUser, string toUser, string msg)
{
User participant = _users[toUser];
if (participant != null)
{
participant.DM(fromUser, msg);
}
}
public override void Register(User user)
{
if (!_users.ContainsValue(user))
{
_users[user.Name] = user;
}
user.Chatroom = this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment