/// <summary> /// Register new user /// </summary> /// <param name="user"></param> /// <returns>user id</returns> public int RegisterUser(VirtualServerEntity.User user) { // create object var newUser = new Dictionary <UserInfo, string>(); foreach (var ui in user.Info) { newUser.Add((UserInfo)ui.Key, ui.Value); } // register user var id = _server.registerUser(newUser); // update id user.Id = id; // set user texture if (user.Texture.Length > 0) { _server.setTexture(id, user.Texture); } // add in cache _entity.Users.Add(id, user); return(id); }
private Agent Add(UUID uuid) { Agent agent = new Agent(uuid); foreach (var user in m_server.getRegisteredUsers(agent.name)) { if (user.Value == agent.name) { m_log.DebugFormat("[MurmurVoice] Found previously registered user {0}", user.Value); m_server.unregisterUser(user.Key); //break; } } agent.userid = m_server.registerUser(agent.user_info); m_log.DebugFormat("[MurmurVoice] Registered {0} (uid {1}) identified by {2}", agent.uuid.ToString(), agent.userid, agent.pass); lock (name_to_agent) name_to_agent[agent.name] = agent; return(agent); }
private Agent Add(UUID uuid, Scene scene) { Agent agent = new Agent(uuid, scene); Dictionary <int, User> users = m_server.getUsers(); foreach (var v in users) { User user = v.Value; if (user.name == agent.name) { m_log.DebugFormat("[MurmurVoice] Found previously registered user {0} {1} {2} {3}", user.name, user.userid, user.session, user.channel); if ((user.userid >= 0) && (user.session >= 0)) { // Reuse Murmur User m_log.DebugFormat("[MurmurVoice] Reusing previously registered user {0} {1} {2} {3}", user.name, user.userid, user.session, user.channel); agent.userid = user.userid; agent.session = user.session; agent.channel = user.channel; lock (name_to_agent) name_to_agent[agent.name] = agent; // Handle password changes m_server.updateRegistration(agent.userid, agent.user_info); return(agent); } else { if (user.userid >= 0) { agent.userid = user.userid; lock (name_to_agent) name_to_agent[agent.name] = agent; // Handle password changes m_server.updateRegistration(agent.userid, agent.user_info); return(agent); } } break; } } lock (name_to_agent) name_to_agent[agent.name] = agent; try { int r = m_server.registerUser(agent.user_info); if (r >= 0) { agent.userid = r; } } catch (Murmur.InvalidUserException) { m_log.Warn("[MurmurVoice] InvalidUserException; continuing to recover later"); } m_log.DebugFormat("[MurmurVoice] Registered {0} (uid {1}) identified by {2}", agent.uuid.ToString(), agent.userid, agent.pass); return(agent); }