public void Joined() { ChatUser user = new ChatUser() { Id = Context.User.Identity.GetUserId(), Username = Context.User.Identity.GetUserName() }; _context.AddUser(user); _context.AddMapping(Context.ConnectionId, user.Id); Clients.All.Joins(user.Id, Context.User.Identity.GetUserName(), DateTime.Now); }
public void Joined() { ApplicationUser user = new ApplicationUser() { Id = ObjectId.GenerateNewId().ToString(), UserName = Clients.Caller.userName }; _repository.Users.Add(user); _repository.AddMapping(Context.ConnectionId, user.Id); Clients.All.joins(user.Id, Clients.Caller.userName, DateTime.Now); }
/// <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, Id = Guid.NewGuid().ToString(), Username = Clients.Caller.username }; _repository.Add(user); _repository.AddMapping(Context.ConnectionId, user.Id); Clients.All.joins(user.Id, Clients.Caller.username, DateTime.Now); }
public async Task Join(string userName) { var connId = this.Context.ConnectionId; if (!_repository.Users.Where(u => u.UserName == userName).Any() && !string.IsNullOrEmpty(userName)) { UserModel user = new UserModel() { Id = Guid.NewGuid().ToString(), UserName = userName }; _repository.Add(user); _repository.AddMapping(Context.ConnectionId, user.Id); } await Clients.All.SendAsync("RefrishUsers", GetUserList()); await Clients.Client(connId).SendAsync("ShowAllMessages", _chatService.GetAllMessage()); }