public void OnUserCountChanged(List <UserActor> data) { foreach (Transform child in areaOfUsers.transform) { GameObject.Destroy(child.gameObject); } foreach (var user in data) { if (user == null) { continue; } JoinedUser temp = Instantiate(Prefab_JoinedUser, areaOfUsers); temp.SetupUser(user.name, user.assetId, user.pos); } }
public IActionResult Join(int ActivityId) { User CurrUser = _context.Users.SingleOrDefault(user => user.UserId == HttpContext.Session.GetInt32("CurrUserId")); Activity CurrActivity = _context.Activities.SingleOrDefault(act => act.ActivityId == ActivityId); JoinedUser AlreadyJoined = _context.JoinedUsers.SingleOrDefault(JU => (JU.ActivityId == CurrActivity.ActivityId) && (JU.UserId == CurrUser.UserId)); if (AlreadyJoined == null) { System.Console.WriteLine("NEW JOINING USER"); } else { System.Console.WriteLine("THIS JOIN ALREADY EXISTS"); } return(RedirectToAction("Dashboard", "Users")); }
private void Server_ReceiveMessage(MessageEventArgs e) { User sender = GetUserBySocket(e.Sender); if (sender != null) { if (sender.Socket == null) { sender.Guid = e.Message.Text; JoinedUser?.Invoke(new UserEventArgs(sender.Guid, sender.Ip, sender.Port)); return; } } if (e.Message.Type == MessageType.Left) { User u = Users.Find((ev) => { return(ev.Guid == e.Message.Text); }); Users.Remove(u); LeftUser?.Invoke(new UserEventArgs(u.Guid, u.Ip, u.Port)); return; } }