private static void CheckForUnknownUserOrRoom(CampfireState campfireInfo, Message msg, ICampfireAPI api) { // If this userId isn't already known... if (!campfireInfo.IsUserKnown(msg.UserId)) { // fetch all the user Info and then add User newUser = api.GetUser(msg.UserId); if ((newUser != null) && (newUser.Type == User.UserType.Member) && !string.IsNullOrEmpty(newUser.Name) && !string.IsNullOrEmpty(newUser.Email)) { Utils.TraceVerboseMessage(string.Format("Found a new User: {0}, Id: {1}", newUser.Name, newUser.Id)); campfireInfo.AddUser(newUser.Id, newUser.Name, newUser.Email, string.Empty); } } // If this roomId isn't already known... if (!campfireInfo.IsRoomKnown(msg.RoomId)) { // fetch all the user Info and then add Room newRoom = api.GetRoom(msg.RoomId); if (newRoom != null) { Utils.TraceVerboseMessage(string.Format("Found a new Room: {0}, Id: {1}", newRoom.Name, newRoom.Id)); campfireInfo.AddRoom(newRoom.Id, newRoom.Name, 0); } } }
/// <summary> /// This is called every so often to check if users Names or Email address has changed, or User has been Deleted /// </summary> /// <param name="campfireInfo"></param> private static void Work_ScanForUserChanges(CampfireState campfireInfo, ICampfireAPI api) { // iterate of all known users... and see if name or email address has changed // Must do this in a thread safe fashion by first getting all the ids. List <int> userIds = campfireInfo.UserIds(); foreach (int uid in userIds) { User user = api.GetUser(uid); if (user != null && !string.IsNullOrEmpty(user.Name) && !string.IsNullOrEmpty(user.Email)) { campfireInfo.UpdateUser(user.Id, user.Name, user.Email); } else { campfireInfo.DeleteUser(uid); } } }
/// <summary> /// This is called every so often to check if users Names or Email address has changed, or User has been Deleted /// </summary> /// <param name="campfireInfo"></param> private static void Work_ScanForUserChanges(CampfireState campfireInfo, ICampfireAPI api) { // iterate of all known users... and see if name or email address has changed // Must do this in a thread safe fashion by first getting all the ids. List<int> userIds = campfireInfo.UserIds(); foreach (int uid in userIds) { User user = api.GetUser(uid); if (user != null && !string.IsNullOrEmpty(user.Name) && !string.IsNullOrEmpty(user.Email)) { campfireInfo.UpdateUser(user.Id, user.Name, user.Email); } else { campfireInfo.DeleteUser(uid); } } }