public byte[] ParcelVoiceInfoRequest(IScene scene, string request,
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}",
scene.RegionInfo.RegionName, land.Name, land.LocalID, avatar.Name, request);
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)
{
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;
return OSDParser.SerializeLLSDXmlBytes(response);
}
catch (Exception e)
{
m_log.ErrorFormat("[MurmurVoice] Exception: " + e);
return MainServer.BadRequest;
}
}