Ejemplo n.º 1
0
 /// <summary>
 /// Fired when a client joins the chat. Here round trip state is available and we can register the user in the list
 /// </summary>
 public void Joined()
 {
     ChatUser user = new ChatUser()
     {
         Id = Context.ConnectionId,
         Username = Clients.Caller.username
     };
     _repository.Add(user);
     Clients.All.joins(Context.ConnectionId, Clients.Caller.username, DateTime.Now);
 }
Ejemplo n.º 2
0
        public void Join(string name)
        {
            ChatUser currentUser = new ChatUser(name, Context.ConnectionId);

            _repository.AddUser(currentUser);

            var users = _repository.Users.Select(user => { return new UserViewModel(user.Value.Name); }).ToList();
            var topic = "Welcome to EmberJS on SignalR!";

            Clients.Caller.lobbyEntered(new ChatRoomViewModel(topic, users));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Fired when a client joins the chat. Here round trip state is available and we can register the user in the list
        /// </summary>
        public void Joined()
        {
            var roomname = Clients.Caller.roomname;
            var user = new ChatUser()
            {
                //Id = Context.ConnectionId, 
                Id = Guid.NewGuid().ToString(),
                Username = Clients.Caller.username,
                Roomname = roomname
            };
            _repository.Add(user);
            _repository.AddMapping(Context.ConnectionId, user.Id);

            Groups.Add(Context.ConnectionId, roomname);

            Clients.Group(roomname).joins(user.Id, Clients.Caller.username, DateTime.Now);
        }
Ejemplo n.º 4
0
 public void AddUser(ChatUser user)
 {
     Users.TryAdd(user.ConnectionId, user);
 }
Ejemplo n.º 5
0
 public void Remove(ChatUser user)
 {
     _connectedUsers.Remove(user);
 }
Ejemplo n.º 6
0
 public void Add(ChatUser user)
 {
     _connectedUsers.Add(user);
 }