public override void userConnected(User state, Ice.Current current) { m_log.DebugFormat("[MurmurVoice] User connected {0} {1} {2}", state.name, state.userid, state.session); if ((state.userid < 0) && (state.session < 0)) { try { m_log.DebugFormat("[MurmurVoice] Kicked user {0} {1}", state.name, state.session); m_manager.Server.kickUser(state.session, "This server requires registration to connect."); } catch (InvalidSessionException) { m_log.DebugFormat("[MurmurVoice] Couldn't kick session {0} {1}", state.name, state.session); } return; } Agent agent = m_manager.Agent.Get(state.name); if (agent != null) { agent.userid = state.userid; agent.session = state.session; AddUserToChan(state, agent.channel); } }
public void AddUserToChan(User state, int channel) { m_log.DebugFormat("[MurmurVoice] AddUserToChan {0} {1} {2} {3}", state.name, state.userid, state.session, channel); if (state.channel != channel) { state.channel = channel; m_manager.Server.setState(state); } }
public override void userStateChanged(User state, Ice.Current current) { }
public override void userDisconnected(User state, Ice.Current current) { m_log.DebugFormat("[MurmurVoice]: userDisconnected {0}",state.userid); }
public override void userConnected(User state, Ice.Current current) { if(state.userid < 0) { try { m_server.kickUser(state.session, "This server requires registration to connect."); } catch (InvalidSessionException) { m_log.DebugFormat("[MurmurVoice] Couldn't kick session {0}", state.session); } return; } try { Agent agent = m_manager.Agent.Get(state.userid); agent.session = state.session; if (agent.channel >= 0 && (state.channel != agent.channel)) { state.channel = agent.channel; m_server.setState(state); } } catch (KeyNotFoundException) { m_log.DebugFormat("[MurmurVoice]: User {0} with userid {1} not registered in murmur manager, ignoring.", state.name, state.userid); } }
/// Callback for a client request for ParcelVoiceInfo public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID) { m_log.Debug("[MurmurVoice] Calling ParcelVoiceInfoRequest..."); try { IScenePresence avatar = scene.GetScenePresence(agentID); string channel_uri = String.Empty; if (null == scene.RequestModuleInterface <IParcelManagementModule>()) { throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatar.Name)); } // get channel_uri: check first whether estate // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel // voice channel LandData land = scene.RequestModuleInterface <IParcelManagementModule>().GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y).LandData; m_log.DebugFormat("[MurmurVoice] region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatar.Name, request, path, param); if (((land.Flags & (uint)ParcelFlags.AllowVoiceChat) > 0) && scene.RegionInfo.EstateSettings.AllowVoice) { Agent agent = GetServerManager(scene).Agent.GetOrCreate(agentID); agent.channel = GetServerManager(scene).Channel.GetOrCreate(ChannelName(scene, land)); // Host/port pair for voice server channel_uri = String.Format("{0}:{1}", m_murmurd_host, m_murmurd_port); if (agent.session > 0) { Murmur.User state = GetServerManager(scene).Server.getState(agent.session); GetServerCallback(scene).AddUserToChan(state, agent.channel); } m_log.DebugFormat("[MurmurVoice] {0}", channel_uri); } else { m_log.DebugFormat("[MurmurVoice] Voice not enabled."); } OSDMap response = new OSDMap(); response["region_name"] = scene.RegionInfo.RegionName; response["parcel_local_id"] = land.LocalID; response["voice_credentials"] = new OSDMap(); ((OSDMap)response["voice_credentials"])["channel_uri"] = channel_uri; string r = OSDParser.SerializeLLSDXmlString(response); m_log.DebugFormat("[MurmurVoice] Parcel: {0}", r); return(r); } catch (Exception e) { m_log.ErrorFormat("[MurmurVoice] Exception: " + e.ToString()); return("<llsd><undef /></llsd>"); } }
/// <summary> /// Returns information about a mumble server via a REST Request /// </summary> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param">A string representing the sim's UUID</param> /// <param name="httpRequest">HTTP request header object</param> /// <param name="httpResponse">HTTP response header object</param> /// <returns>Information about the mumble server in http response headers</returns> public string RestGetMumbleServerInfo(Scene scene, string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { if (m_murmurd_host == null) { httpResponse.StatusCode = 404; httpResponse.StatusDescription = "Not Found"; string message = "[MUMBLE VOIP]: Server info request from " + httpRequest.RemoteIPEndPoint.Address + ". Cannot send response, module is not configured properly."; m_log.Warn(message); return("Mumble server info is not available."); } if (httpRequest.Headers.GetValues("avatar_uuid") == null) { httpResponse.StatusCode = 400; httpResponse.StatusDescription = "Bad Request"; string message = "[MUMBLE VOIP]: Invalid server info request from " + httpRequest.RemoteIPEndPoint.Address + ""; m_log.Warn(message); return("avatar_uuid header is missing"); } string avatar_uuid = httpRequest.Headers.GetValues("avatar_uuid")[0]; string responseBody = String.Empty; UUID avatarId; if (UUID.TryParse(avatar_uuid, out avatarId)) { if (scene == null) { throw new Exception("[MurmurVoice] Invalid scene."); } Agent agent = GetServerManager(scene).Agent.GetOrCreate(avatarId); string channel_uri; IScenePresence avatar = scene.GetScenePresence(avatarId); // get channel_uri: check first whether estate // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel // voice channel LandData land = scene.RequestModuleInterface <IParcelManagementModule>().GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y).LandData; m_log.DebugFormat("[MurmurVoice] region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatar.Name, request, path, param); if (((land.Flags & (uint)ParcelFlags.AllowVoiceChat) > 0) && scene.RegionInfo.EstateSettings.AllowVoice) { agent.channel = GetServerManager(scene).Channel.GetOrCreate(ChannelName(scene, land)); // Host/port pair for voice server channel_uri = String.Format("{0}:{1}", m_murmurd_host, m_murmurd_port); if (agent.session > 0) { Murmur.User state = GetServerManager(scene).Server.getState(agent.session); GetServerCallback(scene).AddUserToChan(state, agent.channel); } m_log.InfoFormat("[MurmurVoice] {0}", channel_uri); } else { m_log.DebugFormat("[MurmurVoice] Voice not enabled."); channel_uri = ""; } string m_context = "Mumble voice system"; httpResponse.AddHeader("Mumble-Server", m_murmurd_host); httpResponse.AddHeader("Mumble-Version", m_server_version); httpResponse.AddHeader("Mumble-Channel", channel_uri); httpResponse.AddHeader("Mumble-User", avatar_uuid); httpResponse.AddHeader("Mumble-Password", agent.pass); httpResponse.AddHeader("Mumble-Avatar-Id", avatar_uuid); httpResponse.AddHeader("Mumble-Context-Id", m_context); responseBody += "Mumble-Server: " + m_murmurd_host + "\n"; responseBody += "Mumble-Version: " + m_server_version + "\n"; responseBody += "Mumble-Channel: " + channel_uri + "\n"; responseBody += "Mumble-User: "******"\n"; responseBody += "Mumble-Password: "******"\n"; responseBody += "Mumble-Avatar-Id: " + avatar_uuid + "\n"; responseBody += "Mumble-Context-Id: " + m_context + "\n"; string log_message = "[MUMBLE VOIP]: Server info request handled for " + httpRequest.RemoteIPEndPoint.Address + ""; m_log.Info(log_message); } else { httpResponse.StatusCode = 400; httpResponse.StatusDescription = "Bad Request"; m_log.Warn("[MUMBLE VOIP]: Could not parse avatar uuid from request"); return("could not parse avatar_uuid header"); } return(responseBody); }
/// Callback for a client request for ParcelVoiceInfo public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID) { m_log.Debug("[MurmurVoice] Calling ParcelVoiceInfoRequest..."); try { ScenePresence avatar = scene.GetScenePresence(agentID); string channel_uri = String.Empty; if (null == scene.LandChannel) { throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatar.Name)); } // get channel_uri: check first whether estate // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel // voice channel LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); if (null == land) { throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatar.Name)); } m_log.DebugFormat("[MurmurVoice] region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatar.Name, request, path, param); if (((land.Flags & (uint)ParcelFlags.AllowVoiceChat) > 0) && scene.RegionInfo.EstateSettings.AllowVoice) { ServerManager manager = GetServerManager(scene); Agent agent = manager.Agent.GetOrCreate(agentID, scene); if (agent == null) { m_log.ErrorFormat("[MurmurVoice] Agent not connected {0}", agentID); return("<llsd><undef /></llsd>"); } agent.channel = manager.Channel.GetOrCreate(ChannelName(scene, land)); // Wait for session connect int retry = 0; while (agent.session < 0) { if (++retry > 50) { m_log.ErrorFormat("[MurmurVoice] Connecting failed {0} (uid {1}) identified by {2}", agent.uuid.ToString(), agent.userid, agent.pass); return("<llsd><undef /></llsd>"); } Thread.Sleep(200); } // Host/port pair for voice server channel_uri = String.Format("{0}:{1}", m_murmurd_host, m_murmurd_port); Murmur.User state = manager.Server.getState(agent.session); GetServerCallback(scene).AddUserToChan(state, agent.channel); m_log.DebugFormat("[MurmurVoice] {0}", channel_uri); } else { m_log.DebugFormat("[MurmurVoice] Voice not enabled."); } Hashtable creds = new Hashtable(); creds["channel_uri"] = channel_uri; LLSDParcelVoiceInfoResponse parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); m_log.DebugFormat("[MurmurVoice] Parcel: {0}", r); return(r); } catch (Exception e) { m_log.ErrorFormat("[MurmurVoice] Exception: " + e.ToString()); return("<llsd><undef /></llsd>"); } }
public override void userDisconnected(User state, Ice.Current current) { Agent agent = m_manager.Agent.Get(state.name); m_log.DebugFormat("[MurmurVoice] User disconnected {0} {1} {2}", state.name, state.userid, state.session); if (agent != null) { agent.session = -1; m_manager.Agent.RemoveAgent(agent.uuid); } }
public override void userDisconnected(User state, Ice.Current current) { try { m_manager.Agent.Get(state.name).session = -1; } catch (KeyNotFoundException) { m_log.DebugFormat("[MurmurVoice]: Userid {0} not handled by murmur manager", state.userid); } }
public void AddUserToChan(User state, int channel) { if (state.channel != channel) { state.channel = channel; m_manager.Server.setState(state); } }