public BakedTextureUploader(Caps caps, string path, IAssetCache assetCache, IJ2KDecoder layerDecoder) { m_uploaderPath = path; m_Caps = caps; m_assetCache = assetCache; m_layerDecoder = layerDecoder; }
public void OnRegisterCaps(UUID agentID, Caps caps) { // m_log.DebugFormat( // "[MOAP]: Registering ObjectMedia and ObjectMediaNavigate capabilities for agent {0}", agentID); string omCapUrl = "/CAPS/" + UUID.Random(); lock (m_omCapUsers) { m_omCapUsers[omCapUrl] = agentID; m_omCapUrls[agentID] = omCapUrl; // Even though we're registering for POST we're going to get GETS and UPDATES too IRequestHandler handler = new RestStreamHandler("POST", omCapUrl, HandleObjectMediaMessage); caps.RegisterHandler("ObjectMedia", handler); } string omuCapUrl = "/CAPS/" + UUID.Random(); lock (m_omuCapUsers) { m_omuCapUsers[omuCapUrl] = agentID; m_omuCapUrls[agentID] = omuCapUrl; // Even though we're registering for POST we're going to get GETS and UPDATES too IRequestHandler handler = new RestStreamHandler("POST", omuCapUrl, HandleObjectMediaNavigateMessage); caps.RegisterHandler("ObjectMediaNavigate", handler); } }
private void DoDeregisterSingleApertureCap(Caps caps, string which) { try { string externalBaseURL = caps.HostName + ":" + m_apPort; string externalURL = caps.CapsHandlers[which].ExternalHandlerURL; string capuuid = externalURL.Replace(externalBaseURL + "/CAPS/HTT/", String.Empty); UUID capID = UUID.Zero; // parse the path and search for the avatar with it registered if (UUID.TryParse(capuuid, out capID)) { string remCapURL = externalBaseURL + REM_CAPS_TOKEN_URL + m_apToken + "/" + capID.ToString(); WebRequest req = WebRequest.Create(remCapURL); HttpWebResponse response = (HttpWebResponse)req.GetResponse(); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Got response '" + response.StatusDescription + "' while trying to deregister CAPS with HTT"); } } } catch (Exception e) { m_log.ErrorFormat( "[APERTURE] Could not contact the aperture texture server to deregister caps on region {0}. Server returned error {1}", caps.RegionName, e.Message); } }
public GetMeshHandler(Scene scene, UUID agentID, Caps caps) { m_Scene = scene; m_AgentID = agentID; m_Caps = caps; m_AssetCache = m_Scene.CommsManager.AssetCache; }
/// <summary> /// OnRegisterCaps is invoked via the scene.EventManager /// everytime OpenSim hands out capabilities to a client /// (login, region crossing). We contribute two capabilities to /// the set of capabilities handed back to the client: /// ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. /// /// ProvisionVoiceAccountRequest allows the client to obtain /// the voice account credentials for the avatar it is /// controlling (e.g., user name, password, etc). /// /// ParcelVoiceInfoRequest is invoked whenever the client /// changes from one region or parcel to another. /// /// Note that OnRegisterCaps is called here via a closure /// delegate containing the scene of the respective region (see /// Initialise()). /// </summary> public void OnRegisterCaps(Scene scene, UUID agentID, Caps caps) { m_log.DebugFormat("[Free Switc hVoice]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); string capsBase = "/CAPS/" + caps.CapsObjectPath; caps.RegisterHandler("ProvisionVoiceAccountRequest", new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return(ProvisionVoiceAccountRequest(scene, request, path, param, agentID, caps)); })); caps.RegisterHandler("ParcelVoiceInfoRequest", new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return(ParcelVoiceInfoRequest(scene, request, path, param, agentID, caps)); })); caps.RegisterHandler("ChatSessionRequest", new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return(ChatSessionRequest(scene, request, path, param, agentID, caps)); })); }
public void OnRegisterCaps(UUID agentID, Caps caps) { m_log.Info("[DATASNAPSHOT]: Registering service discovery capability for " + agentID); string capsBase = "/CAPS/" + caps.CapsObjectPath; caps.RegisterHandler("PublicSnapshotDataInfo", new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt)); }
public void RegisterCaps(UUID agentID, Caps caps) { SeedCapsHandler handler = new SeedCapsHandler(m_scene, agentID, caps); IRequestHandler reqHandler = new RestStreamHandler("POST", caps.CapsBase + m_requestPath, handler.SeedCapRequest); caps.RegisterHandler("SEED", reqHandler); m_log.DebugFormat("[CAPS]: Registered seed capability {0} for {1}", caps.CapsBase + m_requestPath, agentID); }
/// <summary> /// Callback for a client request for ChatSessionRequest /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ChatSessionRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); string avatarName = avatar.Name; m_log.DebugFormat("[FreeSwitchVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", avatarName, request, path, param); return("<llsd>true</llsd>"); }
public void DeregisterCaps(UUID agentID, Caps caps) { if (m_useAperture == true) { string[] deregister = { "GetTexture", "GetMesh" }; foreach (string which in deregister) { DoDeregisterSingleApertureCap(caps, which); } } }
private void SetApertureBandwidth(Caps caps, UUID capID, int bwMax) { string externalBaseURL = GetApertureBaseURL(caps); string addCapURL = externalBaseURL + LIMIT_TOKEN_URL + m_apToken + "/" + capID.ToString() + "/" + bwMax.ToString(); WebRequest req = WebRequest.Create(addCapURL); HttpWebResponse response = (HttpWebResponse)req.GetResponse(); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Got response '" + response.StatusDescription + "' while trying to limit aperture services"); } }
private void PauseAperture(Caps caps, UUID capID) { string externalBaseURL = GetApertureBaseURL(caps); string addCapURL = externalBaseURL + PAUSE_TOKEN_URL + m_apToken + "/" + capID.ToString(); WebRequest req = WebRequest.Create(addCapURL); HttpWebResponse response = (HttpWebResponse)req.GetResponse(); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Got response '" + response.StatusDescription + "' while trying to pause aperture services"); } }
public void OnRegisterCaps(UUID agentID, Caps caps) { //m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); string capsBase = "/CAPS/" + caps.CapsObjectPath; caps.RegisterHandler("MapLayer", new RestStreamHandler("POST", capsBase + m_mapLayerPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return(MapLayerRequest(request, path, param, agentID, caps)); })); }
/// <summary> /// Callback for a map layer request /// </summary> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string MapLayerRequest(string request, string path, string param, UUID agentID, Caps caps) { //try //{ //m_log.DebugFormat("[MAPLAYER]: request: {0}, path: {1}, param: {2}, agent:{3}", //request, path, param,agentID.ToString()); // this is here because CAPS map requests work even beyond the 10,000 limit. ScenePresence avatarPresence = null; m_scene.TryGetAvatar(agentID, out avatarPresence); if (avatarPresence != null) { bool lookup = false; lock (cachedMapBlocks) { if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) { List <MapBlockData> mapBlocks; mapBlocks = cachedMapBlocks; avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); } else { lookup = true; } } if (lookup) { List <MapBlockData> mapBlocks; mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); lock (cachedMapBlocks) cachedMapBlocks = mapBlocks; cachedTime = Util.UnixTimeSinceEpoch(); } } LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); return(mapResponse.ToString()); }
public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) { Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 400; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["str_response_string"] = "Request wasn't what was expected"; UUID meshID = UUID.Zero; if ((request.ContainsKey("mesh_id")) && (UUID.TryParse(request["mesh_id"].ToString(), out meshID))) { if (m_AssetCache == null) { responsedata["int_response_code"] = 404; //501; //410; //404; responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; return(responsedata); } AssetBase mesh = m_AssetCache.GetAsset(meshID, AssetRequestInfo.GenericNetRequest()); if (mesh != null) { if (mesh.Type == (SByte)AssetType.Mesh) { responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); responsedata["content_type"] = "application/vnd.ll.mesh"; responsedata["int_response_code"] = 200; } // Optionally add additional mesh types here else { responsedata["int_response_code"] = 404; //501; //410; //404; responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; return(responsedata); } } else { responsedata["int_response_code"] = 404; //501; //410; //404; responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; return(responsedata); } } return(responsedata); }
public void OnDeregisterCaps(UUID agentID, Caps caps) { lock (m_omCapUsers) { string path = m_omCapUrls[agentID]; m_omCapUrls.Remove(agentID); m_omCapUsers.Remove(path); } lock (m_omuCapUsers) { string path = m_omuCapUrls[agentID]; m_omuCapUrls.Remove(agentID); m_omuCapUsers.Remove(path); } }
public ICapsControl CreateCaps(UUID agentId, string capsPath) { Caps caps = null; lock (m_syncRoot) { if (m_capsObjects.TryGetValue(agentId, out caps)) { m_log.WarnFormat("[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ", agentId, caps.CapsObjectPath, capsPath); } caps = new Caps(MainServer.Instance, capsPath, agentId, m_scene.RegionInfo.RegionName); m_capsObjects[agentId] = caps; } m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); return(new CapsControl(agentId, this)); }
private void OnRegisterCaps(UUID agentID, Caps caps) { // m_log.DebugFormat("[{0}]: Register capability for agentID {1} in region {2}", // Name, agentID, caps.RegionName); string capsPath = capsBase + UUID.Random(); // Get handler caps.RegisterHandler( capsName, new RestStreamHandler( "GET", capsPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return(GetEnvironmentSettings(agentID)); })); // Set handler caps.RegisterHandler( capsName, new RestStreamHandler( "POST", capsPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { string result = SetEnvironmentSettings(request, agentID); if (result == null) { return(String.Empty); } return(result); })); }
private string SetEnvironmentSettings(string request, string path, string param, UUID agentID, Caps caps) { LLSDEnvironmentSetResponse setResponse = new LLSDEnvironmentSetResponse(); m_log.WarnFormat("[{0}]: Environment POST handler for agentID {1}", Name, agentID); setResponse.regionID = regionID; setResponse.success = false; if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false)) { setResponse.fail_reason = "Insufficient estate permissions, settings has not been saved."; return(LLSDHelpers.SerializeLLSDReply(setResponse)); } try { m_scene.StorageManager.DataStore.StoreRegionEnvironmentString(regionID, request); setResponse.success = true; m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}", Name, agentID, caps.RegionName); } catch (Exception e) { m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}", Name, caps.RegionName, e.Message, e.StackTrace); setResponse.success = false; setResponse.fail_reason = String.Format("Environment Set for region {0} has failed, settings has not been saved.", caps.RegionName); } string response = LLSDHelpers.SerializeLLSDReply(setResponse); return(response); }
private string GetEnvironmentSettings(string request, string path, string param, UUID agentID, Caps caps) { m_log.WarnFormat("[{0}]: Environment GET handler for agentID {1}", Name, agentID); string response = String.Empty; try { response = m_scene.StorageManager.DataStore.LoadRegionEnvironmentString(regionID); } catch (Exception e) { m_log.ErrorFormat("[{0}]: Unable to load environment settings for region {1}, Exception: {2} - {3}", Name, caps.RegionName, e.Message, e.StackTrace); } if (String.IsNullOrEmpty(response)) { response = EnvironmentSettings.EmptySettings(UUID.Zero, regionID); } return(response); }
public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { m_log.DebugFormat( "[FreeSwitchVoice][PARCELVOICE]: ParcelVoiceInfoRequest() request: {0}, path: {1}, param: {2}", request, path, param); ScenePresence avatar = scene.GetScenePresence(agentID); if (avatar == null) // seen on the main grid, perhaps on user disconnect or viewer crash { return(EMPTY_RESPONSE); } string avatarName = avatar.Name; // - check whether we have a region channel in our cache // - if not: // create it and cache it // - send it to the client // - send channel_uri: as "sip:regionID@m_sipDomain" try { LLSDParcelVoiceInfoResponse parcelVoiceInfo; string channel_uri; if (null == scene.LandChannel) { throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatarName)); } // If the avatar is in transit between regions, avatar.AbsolutePosition calls below can return undefined values. if (avatar.IsInTransit) { m_log.WarnFormat("[FreeSwitchVoice][PARCELVOICE]: Cannot process voice info request - avatar {0} is still in transit between regions.", avatarName); return(EMPTY_RESPONSE); } // 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 Vector3 pos = avatar.AbsolutePosition; // take a copy to avoid double recalc LandData land = scene.GetLandData(pos.X, pos.Y); if (land == null) { // m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar\"{1}\" at ({2}): Land parcel not found.", // scene.RegionInfo.RegionName, avatarName, pos.ToString()); return(EMPTY_RESPONSE); } // TODO: EstateSettings don't seem to get propagated... if (!scene.RegionInfo.EstateSettings.AllowVoice) { m_log.InfoFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings", scene.RegionInfo.RegionName); channel_uri = String.Empty; } if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) { m_log.InfoFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); channel_uri = String.Empty; } else { channel_uri = RegionGetOrCreateChannel(scene, land); } // fill in our response to the client Hashtable creds = new Hashtable(); creds["channel_uri"] = channel_uri; parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerializeLLSDReply(parcelVoiceInfo); return(r); } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", scene.RegionInfo.RegionName, avatarName, e.Message); m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} exception", scene.RegionInfo.RegionName, avatarName, e.ToString()); return(EMPTY_RESPONSE); } }
public void RegisterCaps(UUID agentID, Caps caps) { UUID capID = UUID.Random(); bool getTextureCapRegistered = false; try { if (m_useAperture == true) { string externalBaseURL = GetApertureBaseURL(caps); string externalURL = GetApertureHttUrl(caps, capID); string addCapURL = externalBaseURL + ADD_CAPS_TOKEN_URL + m_apToken + "/" + capID.ToString(); WebRequest req = WebRequest.Create(addCapURL); HttpWebResponse response = (HttpWebResponse)req.GetResponse(); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Got response '" + response.StatusDescription + "' while trying to register CAPS with HTT"); } //register this cap url with the server caps.RegisterHandler("GetTexture", externalURL, () => this.PauseAperture(caps, capID), () => this.ResumeAperture(caps, capID), (int bwMax) => this.SetApertureBandwidth(caps, capID, bwMax)); getTextureCapRegistered = true; } } catch (Exception e) { m_log.ErrorFormat( "[APERTURE] Could not contact the aperture texture server to register caps on region {0}. Server returned error {1}", caps.RegionName, e.Message); } if (getTextureCapRegistered == false) { #if false // If we get here aperture is either disabled or we failed to contact it IRequestHandler handler = new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString()); caps.RegisterHandler("GetTexture", handler); // m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); #endif } IRequestHandler requestHandler; ISimulatorFeaturesModule SimulatorFeatures = m_Scene.RequestModuleInterface<ISimulatorFeaturesModule>(); if ((SimulatorFeatures != null) && (SimulatorFeatures.MeshEnabled == true)) { //use the same cap ID for mesh and HTT. That way the token bucket in aperture will balance the //available bandwidth between mesh and http textures //capID = UUID.Random(); bool getMeshCapRegistered = false; try { if (m_useAperture == true) { string externalBaseURL = GetApertureBaseURL(caps); string externalURL = GetApertureHttUrl(caps, capID); //register this cap url with the server caps.RegisterHandler("GetMesh", externalURL); //caps control for the texture server will apply to pause mesh as well getMeshCapRegistered = true; } } catch (Exception e) { m_log.ErrorFormat( "[APERTURE] Could not contact the aperture texture server to register caps on region {0}. Server returned error {1}", caps.RegionName, e.Message); } if (getMeshCapRegistered == false) { // m_log.DebugFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); GetMeshHandler gmeshHandler = new GetMeshHandler(m_Scene, agentID, caps); requestHandler = new RestHTTPHandler( "GET", "/CAPS/" + UUID.Random(), httpMethod => gmeshHandler.ProcessGetMesh(httpMethod, UUID.Zero, null)); caps.RegisterHandler("GetMesh", requestHandler); } } // Upload Baked Texture UploadBakedTextureHandler uploadHandler = new UploadBakedTextureHandler(m_Scene, caps); requestHandler = new RestStreamHandler("POST", "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, uploadHandler.UploadBakedTexture); caps.RegisterHandler("UploadBakedTexture", requestHandler); requestHandler = new RestStreamHandler("POST", caps.CapsBase + "/" + UUID.Random(), GetObjectCostHandler); caps.RegisterHandler("GetObjectCost", requestHandler); requestHandler = new RestStreamHandler("POST", caps.CapsBase + "/" + UUID.Random(), ResourceCostsSelected); caps.RegisterHandler("ResourceCostSelected", requestHandler); requestHandler = new RestStreamHandler("POST", caps.CapsBase + "/" + UUID.Random(), GetObjectPhysicsDataHandler); caps.RegisterHandler("GetObjectPhysicsData", requestHandler); }
/// <summary> /// Callback for a client request for ParcelVoiceInfo /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); string avatarName = avatar.Name; // - check whether we have a region channel in our cache // - if not: // create it and cache it // - send it to the client // - send channel_uri: as "sip:regionID@m_sipDomain" try { LLSDParcelVoiceInfoResponse parcelVoiceInfo; string channelUri; if (null == scene.LandChannel) throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatarName)); // 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); m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); // TODO: EstateSettings don't seem to get propagated... // if (!scene.RegionInfo.EstateSettings.AllowVoice) // { // m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings", // scene.RegionInfo.RegionName); // channel_uri = String.Empty; // } // else if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) { m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); channelUri = String.Empty; } else { channelUri = ChannelUri(scene, land); } // fill in our response to the client Hashtable creds = new Hashtable(); creds["channel_uri"] = channelUri; parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerializeLLSDReply(parcelVoiceInfo); m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); return r; } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", scene.RegionInfo.RegionName, avatarName, e.Message); m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", scene.RegionInfo.RegionName, avatarName, e.ToString()); return "<llsd>undef</llsd>"; } }
public void RegisterCaps(UUID agentID, Caps caps) { UUID capID = UUID.Random(); try { if (m_useAperture == true) { string externalBaseURL = GetApertureBaseURL(caps); string externalURL = GetApertureHttUrl(caps, capID); string addCapURL = externalBaseURL + ADD_CAPS_TOKEN_URL + m_apToken + "/" + capID.ToString(); WebRequest req = WebRequest.Create(addCapURL); HttpWebResponse response = (HttpWebResponse)req.GetResponse(); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Got response '" + response.StatusDescription + "' while trying to register CAPS with HTT"); } //register this cap url with the server caps.RegisterHandler("GetTexture", externalURL, () => this.PauseAperture(caps, capID), () => this.ResumeAperture(caps, capID), (int bwMax) => this.SetApertureBandwidth(caps, capID, bwMax)); } } catch (Exception e) { m_log.ErrorFormat( "[APERTURE] Could not contact the aperture texture server to register caps on region {0}. Server returned error {1}", caps.RegionName, e.Message); } IRequestHandler requestHandler; ISimulatorFeaturesModule SimulatorFeatures = m_Scene.RequestModuleInterface <ISimulatorFeaturesModule>(); if ((SimulatorFeatures != null) && (SimulatorFeatures.MeshEnabled == true)) { //use the same cap ID for mesh and HTT. That way the token bucket in aperture will balance the //available bandwidth between mesh and http textures //capID = UUID.Random(); bool getMeshCapRegistered = false; try { if (m_useAperture == true) { string externalBaseURL = GetApertureBaseURL(caps); string externalURL = GetApertureHttUrl(caps, capID); //register this cap url with the server caps.RegisterHandler("GetMesh", externalURL); //caps control for the texture server will apply to pause mesh as well getMeshCapRegistered = true; } } catch (Exception e) { m_log.ErrorFormat( "[APERTURE] Could not contact the aperture texture server to register caps on region {0}. Server returned error {1}", caps.RegionName, e.Message); } if (getMeshCapRegistered == false) { // m_log.DebugFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); GetMeshHandler gmeshHandler = new GetMeshHandler(m_Scene, agentID, caps); requestHandler = new RestHTTPHandler( "GET", "/CAPS/" + UUID.Random(), httpMethod => gmeshHandler.ProcessGetMesh(httpMethod, UUID.Zero, null)); caps.RegisterHandler("GetMesh", requestHandler); } } // Upload Baked Texture UploadBakedTextureHandler uploadHandler = new UploadBakedTextureHandler(m_Scene, caps); requestHandler = new RestStreamHandler("POST", "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, uploadHandler.UploadBakedTexture); caps.RegisterHandler("UploadBakedTexture", requestHandler); requestHandler = new RestStreamHandler("POST", caps.CapsBase + "/" + UUID.Random(), GetObjectCostHandler); caps.RegisterHandler("GetObjectCost", requestHandler); requestHandler = new RestStreamHandler("POST", caps.CapsBase + "/" + UUID.Random(), ResourceCostsSelected); caps.RegisterHandler("ResourceCostSelected", requestHandler); requestHandler = new RestStreamHandler("POST", caps.CapsBase + "/" + UUID.Random(), GetObjectPhysicsDataHandler); caps.RegisterHandler("GetObjectPhysicsData", requestHandler); }
public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) { Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 400; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["str_response_string"] = "Request wasn't what was expected"; UUID meshID = UUID.Zero; if ((request.ContainsKey("mesh_id")) && (UUID.TryParse(request["mesh_id"].ToString(), out meshID))) { if (m_AssetCache == null) { responsedata["int_response_code"] = 404; //501; //410; //404; responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; return responsedata; } AssetBase mesh = m_AssetCache.GetAsset(meshID, AssetRequestInfo.GenericNetRequest()); if (mesh != null) { if (mesh.Type == (SByte)AssetType.Mesh) { responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); responsedata["content_type"] = "application/vnd.ll.mesh"; responsedata["int_response_code"] = 200; } // Optionally add additional mesh types here else { responsedata["int_response_code"] = 404; //501; //410; //404; responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; return responsedata; } } else { responsedata["int_response_code"] = 404; //501; //410; //404; responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; return responsedata; } } return responsedata; }
/// <summary> /// Callback for a map layer request /// </summary> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string MapLayerRequest(string request, string path, string param, UUID agentID, Caps caps) { //try //{ //m_log.DebugFormat("[MAPLAYER]: request: {0}, path: {1}, param: {2}, agent:{3}", //request, path, param,agentID.ToString()); // this is here because CAPS map requests work even beyond the 10,000 limit. ScenePresence avatarPresence = null; m_scene.TryGetAvatar(agentID, out avatarPresence); if (avatarPresence != null) { bool lookup = false; lock (cachedMapBlocks) { if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) { List<MapBlockData> mapBlocks; mapBlocks = cachedMapBlocks; avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); } else { lookup = true; } } if (lookup) { List<MapBlockData> mapBlocks; mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); avatarPresence.ControllingClient.SendMapBlock(mapBlocks,0); lock (cachedMapBlocks) cachedMapBlocks = mapBlocks; cachedTime = Util.UnixTimeSinceEpoch(); } } LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); return mapResponse.ToString(); }
public UploadBakedTextureHandler(Scene scene, Caps caps) { m_Scene = scene; m_Caps = caps; }
public ICapsControl CreateCaps(UUID agentId, string capsPath) { Caps caps = null; lock (m_syncRoot) { if (m_capsObjects.TryGetValue(agentId, out caps)) { m_log.WarnFormat("[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ", agentId, caps.CapsObjectPath, capsPath); } caps = new Caps(MainServer.Instance, capsPath, agentId, m_scene.RegionInfo.RegionName); m_capsObjects[agentId] = caps; } m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); return new CapsControl(agentId, this); }
// we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the // "real" parcelID, because we wouldn't be able to map that to the region the parcel belongs to. // So, we create a "fake" parcelID by using the regionHandle (64 bit), and the local (integer) x // and y coordinate (each 8 bit), encoded in a UUID (128 bit). // // Request format: // <llsd> // <map> // <key>location</key> // <array> // <real>1.23</real> // <real>45..6</real> // <real>78.9</real> // </array> // <key>region_id</key> // <uuid>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</uuid> // </map> // </llsd> private string RemoteParcelRequest(string request, string path, string param, UUID agentID, Caps caps) { UUID parcelID = UUID.Zero; try { Hashtable hash = new Hashtable(); hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); if (hash.ContainsKey("location")) { ArrayList list = (ArrayList)hash["location"]; uint x = (uint)(double)list[0]; uint y = (uint)(double)list[1]; if (hash.ContainsKey("region_handle")) { // if you do a "About Landmark" on a landmark a second time, the viewer sends the // region_handle it got earlier via RegionHandleRequest ulong regionHandle = Util.BytesToUInt64Big((byte[])hash["region_handle"]); parcelID = Util.BuildFakeParcelID(regionHandle, x, y); } else { // region_id case UUID regionID = UUID.Zero; if (hash.ContainsKey("region_id")) regionID = (UUID)hash["region_id"]; if (regionID == UUID.Zero) m_log.Warn("[LAND]: RemoteParcelRequest got null or missing region ID."); else if (regionID == m_scene.RegionInfo.RegionID) { // a parcel request for a local parcel => no need to query the grid parcelID = Util.BuildFakeParcelID(m_scene.RegionInfo.RegionHandle, x, y); } else { // a parcel request for a parcel in another region. Ask the grid about the region RegionInfo info = m_scene.CommsManager.GridService.RequestNeighbourInfo(regionID); if (info != null) parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y); } } } } catch (LLSD.LLSDParseException e) { m_log.ErrorFormat("[LAND]: Fetch error: {0}", e.Message); m_log.ErrorFormat("[LAND]: ... in request {0}", request); } catch(InvalidCastException) { m_log.ErrorFormat("[LAND]: Wrong type in request {0}", request); } LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse(); response.parcel_id = parcelID; m_log.DebugFormat("[LAND]: got parcelID {0}", parcelID); return LLSDHelpers.SerializeLLSDReply(response); }
private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps) { IClientAPI client; if (!m_scene.TryGetClient(agentID, out client)) { m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID); return LLSDHelpers.SerializeLLSDReply(new LLSDEmpty()); } ParcelPropertiesUpdateMessage properties = new ParcelPropertiesUpdateMessage(); OpenMetaverse.StructuredData.OSDMap args = (OpenMetaverse.StructuredData.OSDMap)OSDParser.DeserializeLLSDXml(request); properties.Deserialize(args); LandUpdateArgs land_update = new LandUpdateArgs(); int parcelID = properties.LocalID; land_update.AuthBuyerID = properties.AuthBuyerID; land_update.Category = properties.Category; land_update.Desc = properties.Desc; land_update.GroupID = properties.GroupID; land_update.LandingType = (byte)properties.Landing; land_update.MediaAutoScale = (byte)Convert.ToInt32(properties.MediaAutoScale); land_update.MediaID = properties.MediaID; land_update.MediaURL = properties.MediaURL; land_update.MusicURL = properties.MusicURL; land_update.Name = properties.Name; land_update.ParcelFlags = (uint)properties.ParcelFlags; land_update.PassHours = (int)properties.PassHours; land_update.PassPrice = (int)properties.PassPrice; land_update.SalePrice = (int)properties.SalePrice; land_update.SnapshotID = properties.SnapshotID; land_update.UserLocation = properties.UserLocation; land_update.UserLookAt = properties.UserLookAt; land_update.MediaDescription = properties.MediaDesc; land_update.MediaType = properties.MediaType; land_update.MediaWidth = properties.MediaWidth; land_update.MediaHeight = properties.MediaHeight; land_update.MediaLoop = properties.MediaLoop; land_update.ObscureMusic = properties.ObscureMusic; land_update.ObscureMedia = properties.ObscureMedia; ILandObject land; lock (m_landList) { m_landList.TryGetValue(parcelID, out land); } if (land != null) { land.updateLandProperties(land_update, client); parcelInfoCache.Invalidate(land.landData.GlobalID.ToString()); m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(land_update, parcelID, client); } else { m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID); } return LLSDHelpers.SerializeLLSDReply(new LLSDEmpty()); }
private void OnRegisterCaps(UUID agentID, Caps caps) { string capsBase = "/CAPS/" + caps.CapsObjectPath; caps.RegisterHandler( "RemoteParcelRequest", new RestStreamHandler( "POST", capsBase + remoteParcelRequestPath, (request, path, param, httpRequest, httpResponse) => RemoteParcelRequest(request, path, param, agentID, caps), "RemoteParcelRequest", agentID.ToString())); UUID parcelCapID = UUID.Random(); caps.RegisterHandler( "ParcelPropertiesUpdate", new RestStreamHandler( "POST", "/CAPS/" + parcelCapID, (request, path, param, httpRequest, httpResponse) => ProcessPropertiesUpdate(request, path, param, agentID, caps), "ParcelPropertiesUpdate", agentID.ToString())); }
public SeedCapsHandler(Scene scene, UUID agentID, Caps caps) { m_Caps = caps; m_Scene = scene; }
private void DoDeregisterSingleApertureCap(Caps caps, string which) { try { string externalBaseURL = caps.HostName + ":" + m_apPort; string externalURL = caps.CapsHandlers[which].ExternalHandlerURL; string capuuid = externalURL.Replace(externalBaseURL + "/CAPS/HTT/", ""); UUID capID = UUID.Zero; // parse the path and search for the avatar with it registered if (UUID.TryParse(capuuid, out capID)) { string remCapURL = externalBaseURL + REM_CAPS_TOKEN_URL + m_apToken + "/" + capID.ToString(); WebRequest req = WebRequest.Create(remCapURL); HttpWebResponse response = (HttpWebResponse)req.GetResponse(); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Got response '" + response.StatusDescription + "' while trying to deregister CAPS with HTT"); } } } catch (Exception e) { m_log.ErrorFormat( "[APERTURE] Could not contact the aperture texture server to deregister caps on region {0}. Server returned error {1}", caps.RegionName, e.Message); } }
private string GetEnvironmentSettings(string request, string path, string param, UUID agentID, Caps caps) { m_log.WarnFormat("[{0}]: Environment GET handler for agentID {1}", Name, agentID); string response = String.Empty; try { response = m_scene.StorageManager.DataStore.LoadRegionEnvironmentString(regionID); } catch (Exception e) { m_log.ErrorFormat("[{0}]: Unable to load environment settings for region {1}, Exception: {2} - {3}", Name, caps.RegionName, e.Message, e.StackTrace); } if (String.IsNullOrEmpty(response)) response = EnvironmentSettings.EmptySettings(UUID.Zero, regionID); return response; }
private string GetApertureHttUrl(Caps caps, UUID capID) { string externalURL = GetApertureBaseURL(caps) + "/CAPS/HTT/" + capID.ToString(); return externalURL; }
private string GetApertureBaseURL(Caps caps) { string externalBaseURL = caps.HostName + ":" + m_apPort; return(externalBaseURL); }
private string GetApertureBaseURL(Caps caps) { string externalBaseURL = caps.HostName + ":" + m_apPort; return externalBaseURL; }
/// <summary> /// Callback for a client request for Voice Account Details /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); if (avatar == null) { System.Threading.Thread.Sleep(2000); avatar = scene.GetScenePresence(agentID); if (avatar == null) return "<llsd>undef</llsd>"; } string avatarName = avatar.Name; try { m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); //XmlElement resp; string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); string password = "******";//temp hack//new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16); // XXX: we need to cache the voice credentials, as // FreeSwitch is later going to come and ask us for // those agentname = agentname.Replace('+', '-').Replace('/', '_'); lock (m_UUIDName) { if (m_UUIDName.ContainsKey(agentname)) { m_UUIDName[agentname] = avatarName; } else { m_UUIDName.Add(agentname, avatarName); } } // LLSDVoiceAccountResponse voiceAccountResponse = // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); string r = LLSDHelpers.SerializeLLSDReply(voiceAccountResponse); m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); return r; } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}, retry later", avatarName, e.Message); m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1} failed", avatarName, e.ToString()); return "<llsd>undef</llsd>"; } }
private string GetApertureHttUrl(Caps caps, UUID capID) { string externalURL = GetApertureBaseURL(caps) + "/CAPS/HTT/" + capID.ToString(); return(externalURL); }
public void DeregisterCaps(UUID agentID, Caps caps) { if (m_useAperture == true) { string[] deregister = {"GetTexture", "GetMesh"}; foreach (string which in deregister) { DoDeregisterSingleApertureCap(caps, which); } } }
/// <summary> /// Callback for a client request for Voice Account Details /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); if (avatar == null) { System.Threading.Thread.Sleep(2000); avatar = scene.GetScenePresence(agentID); if (avatar == null) { return("<llsd>undef</llsd>"); } } string avatarName = avatar.Name; try { m_log.DebugFormat("[Free Switch Voice][Provision Voice]: request: {0}, path: {1}, param: {2}", request, path, param); string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); string password = "******";//temp hack//new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16); // we need to cache the voice credentials, as // FreeSwitch is later going to come and ask us for // those agentname = agentname.Replace('+', '-').Replace('/', '_'); lock (m_UUIDName) { if (m_UUIDName.ContainsKey(agentname)) { m_UUIDName[agentname] = avatarName; } else { m_UUIDName.Add(agentname, avatarName); } } LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); m_log.DebugFormat("[Free Switch Voice][Provision Voice]: avatar \"{0}\": {1}", avatarName, r); return(r); } catch (Exception e) { m_log.ErrorFormat("[Free Switch Voice][Provision Voice]: avatar \"{0}\": {1}, retry later", avatarName, e.Message); m_log.DebugFormat("[Free Switch Voice][Provision Voice]: avatar \"{0}\": {1} failed", avatarName, e.ToString()); return("<llsd>undef</llsd>"); } }
/// <summary> /// Callback for a client request for ParcelVoiceInfo /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); string avatarName = avatar.Name; // - check whether we have a region channel in our cache // - if not: // create it and cache it // - send it to the client // - send channel_uri: as "sip:regionID@m_sipDomain" try { LLSDParcelVoiceInfoResponse parcelVoiceInfo; string channelUri; if (null == scene.LandChannel) { throw new Exception(String.Format("retion \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.Regionname, avatarName)); } // 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); m_log.DebugFormat("[Free Switch Voice][Parcel Voice]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); if ((land.Flags & (uint)Parcel.ParcelFlags.AllowVoiceChat) == 0) { m_log.DebugFormat("[Free Switch Voice][Parcel Voice]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); channelUri = String.Empty; } else { channelUri = ChannelUri(scene, land); } // fill in our response to the client Hashtable creds = new Hashtable(); creds["channel_uri"] = channelUri; parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); m_log.DebugFormat("[Free Switch Voice][Parcel Voice]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); return(r); } catch (Exception e) { m_log.ErrorFormat("[Free Switch Voice][Parcel Voice]: region \"{0}\": avatar \"{1}\": {2}, retry later", scene.RegionInfo.RegionName, avatarName, e.Message); m_log.DebugFormat("[Free Switch Voice][Parcel Voice]: region \"{0}\": avatar \"{1}\": {2} failed", scene.RegionInfo.RegionName, avatarName, e.ToString()); return("<llsd>undef</llsd>"); } }
public string ChatSessionRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { return("<llsd>true</llsd>"); }
// <summary> // OnRegisterCaps is invoked via the scene.EventManager // everytime OpenSim hands out capabilities to a client // (login, region crossing). We contribute two capabilities to // the set of capabilities handed back to the client: // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. // // ProvisionVoiceAccountRequest allows the client to obtain // the voice account credentials for the avatar it is // controlling (e.g., user name, password, etc). // // ParcelVoiceInfoRequest is invoked whenever the client // changes from one region or parcel to another. // // Note that OnRegisterCaps is called here via a closure // delegate containing the scene of the respective region (see // Initialize()). // </summary> public void OnRegisterCaps(Scene scene, UUID agentID, Caps caps) { //m_log.DebugFormat("[VivoxVoice] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); string capsBase = "/CAPS/" + caps.CapsObjectPath; caps.RegisterHandler("ProvisionVoiceAccountRequest", new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return ProvisionVoiceAccountRequest(scene, request, path, param, agentID, caps); })); caps.RegisterHandler("ParcelVoiceInfoRequest", new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return ParcelVoiceInfoRequest(scene, request, path, param, agentID, caps); })); caps.RegisterHandler("ChatSessionRequest", new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return ChatSessionRequest(scene, request, path, param, agentID, caps); })); }
public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { m_log.DebugFormat( "[FreeSwitchVoice][PROVISIONVOICE]: ProvisionVoiceAccountRequest() request: {0}, path: {1}, param: {2}", request, path, param); try { ScenePresence avatar = null; string avatarName = null; int avatarWait = 10000; // milliseconds int sleepWait = 100; // milliseconds if (scene == null) { throw new Exception("[FreeSwitchVoice][PROVISIONVOICE] Invalid scene"); } avatar = scene.GetScenePresence(agentID); while (avatar == null || avatar.IsInTransit) { if (avatarWait <= 0) { m_log.WarnFormat("[FreeSwitchVoice][PROVISIONVOICE]: Timeout waiting for agent {0} to enter scene.", agentID); return(EMPTY_RESPONSE); } Thread.Sleep(sleepWait); avatarWait -= sleepWait; avatar = scene.GetScenePresence(agentID); } avatarName = avatar.Name; if (!scene.EventManager.TriggerOnBeforeProvisionVoiceAccount(agentID, avatarName)) { return(EMPTY_RESPONSE); } m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: scene = {0}, agentID = {1}", scene, agentID); m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); string code = String.Empty; agentname = agentname.Replace('+', '-').Replace('/', '_'); UserAccount account = null; if (GetVoiceAccountInfo(agentname, avatarName, out account)) { LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agentname, account.password, account.realm, String.Format("http://{0}/{1}", m_realm, m_apiPrefix)); string r = LLSDHelpers.SerializeLLSDReply(voiceAccountResponse); m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); return(r); } m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: Get Account Request failed for \"{0}\"", avatarName); throw new Exception("Unable to execute request"); } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice][PROVISIONVOICE]: : {0}, retry later", e.Message); m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: : {0} failed", e.ToString()); return(EMPTY_RESPONSE); } }
/// <summary> /// Callback for a client request for Voice Account Details /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { try { ScenePresence avatar = null; string avatarName = null; int avatarWait = 10000; // milliseconds int sleepWait = 100; // milliseconds if (scene == null) throw new Exception("[VivoxVoice][PROVISIONVOICE] Invalid scene"); avatar = scene.GetScenePresence(agentID); while (avatar == null || avatar.IsInTransit) { if (avatarWait <= 0) { m_log.WarnFormat("[VivoxVoice][PROVISIONVOICE]: Timeout waiting for agent {0} to enter scene.", agentID); return EMPTY_RESPONSE; } Thread.Sleep(sleepWait); avatarWait -= sleepWait; avatar = scene.GetScenePresence(agentID); } avatarName = avatar.Name; if (!scene.EventManager.TriggerOnBeforeProvisionVoiceAccount(agentID, avatarName)) { return EMPTY_RESPONSE; } m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: scene = {0}, agentID = {1}", scene, agentID); m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); XmlElement resp; bool retry = false; string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); string password = new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16); string code = String.Empty; agentname = agentname.Replace('+', '-').Replace('/', '_'); do { resp = VivoxGetAccountInfo(agentname); if (XmlFind(resp, "response.level0.status", out code)) { if (code != "OK") { if (XmlFind(resp, "response.level0.body.code", out code)) { // If the request was recognized, then this should be set to something switch (code) { case "201" : // Account expired m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : expired credentials", avatarName); m_adminConnected = false; retry = DoAdminLogin(); break; case "202" : // Missing credentials m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : missing credentials", avatarName); break; case "212" : // Not authorized m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : not authorized", avatarName); break; case "300" : // Required parameter missing m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : parameter missing", avatarName); break; case "403" : // Account does not exist resp = VivoxCreateAccount(agentname,password); // Note: This REALLY MUST BE status. Create Account does not return code. if (XmlFind(resp, "response.level0.status", out code)) { switch (code) { case "201" : // Account expired m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : expired credentials", avatarName); m_adminConnected = false; retry = DoAdminLogin(); break; case "202" : // Missing credentials m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : missing credentials", avatarName); break; case "212" : // Not authorized m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : not authorized", avatarName); break; case "300" : // Required parameter missing m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : parameter missing", avatarName); break; case "400" : // Create failed m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : create failed", avatarName); break; } } break; case "404" : // Failed to retrieve account m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : retrieve failed"); // [AMW] Sleep and retry for a fixed period? Or just abandon? break; } } } } } while (retry); if (code != "OK") { m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: Get Account Request failed for \"{0}\"", avatarName); throw new Exception("Unable to execute request"); } // Unconditionally change the password on each request VivoxPassword(agentname, password); LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agentname, password, m_vivoxSipUri, m_vivoxVoiceAccountApi); string r = LLSDHelpers.SerializeLLSDReply(voiceAccountResponse); m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); return r; } catch (Exception e) { m_log.ErrorFormat("[VivoxVoice][PROVISIONVOICE]: : {0}, retry later", e.Message); m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: : {0} failed", e.ToString()); return EMPTY_RESPONSE; } }
/// <summary> /// Callback for a client request for ParcelVoiceInfo /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); if (avatar == null) // seen on the main grid, perhaps on user disconnect or viewer crash return EMPTY_RESPONSE; string avatarName = avatar.Name; // - check whether we have a region channel in our cache // - if not: // create it and cache it // - send it to the client // - send channel_uri: as "sip:regionID@m_sipDomain" try { LLSDParcelVoiceInfoResponse parcelVoiceInfo; string channel_uri; if (null == scene.LandChannel) throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatarName)); // If the avatar is in transit between regions, avatar.AbsolutePosition calls below can return undefined values. if (avatar.IsInTransit) { m_log.WarnFormat("[VivoxVoice][PARCELVOICE]: Cannot process voice info request - avatar {0} is still in transit between regions.", avatarName); return EMPTY_RESPONSE; } // 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 (land == null) { // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar\"{1}\" at ({2}): Land parcel not found.", // scene.RegionInfo.RegionName, avatarName, avatar.AbsolutePosition.ToString()); return EMPTY_RESPONSE; } // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: avatar \"{0}\": location: {1} {2} {3}", // avatarName, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); // TODO: EstateSettings don't seem to get propagated... if (!scene.RegionInfo.EstateSettings.AllowVoice) { m_log.InfoFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings", scene.RegionInfo.RegionName); channel_uri = String.Empty; } if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) { m_log.InfoFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); channel_uri = String.Empty; } else { channel_uri = RegionGetOrCreateChannel(scene, land); } // fill in our response to the client Hashtable creds = new Hashtable(); creds["channel_uri"] = channel_uri; parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerializeLLSDReply(parcelVoiceInfo); // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); return r; } catch (Exception e) { m_log.ErrorFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", scene.RegionInfo.RegionName, avatarName, e.Message); m_log.ErrorFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} exception", scene.RegionInfo.RegionName, avatarName, e.ToString()); return EMPTY_RESPONSE; } }
public void OnRegisterCaps(UUID agentID, Caps caps) { //m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); string capsBase = "/CAPS/" + caps.CapsObjectPath; caps.RegisterHandler("MapLayer", new RestStreamHandler("POST", capsBase + m_mapLayerPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return MapLayerRequest(request, path, param, agentID, caps); })); }
/// <summary> /// Callback for a client request for a private chat channel /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ChatSessionRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); string avatarName = avatar.Name; //m_log.DebugFormat("[VivoxVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", // avatarName, request, path, param); return "<llsd>true</llsd>"; }
private void OnRegisterCaps(UUID agentID, Caps caps) { // m_log.DebugFormat("[{0}]: Register capability for agentID {1} in region {2}", // Name, agentID, caps.RegionName); string capsPath = capsBase + UUID.Random(); // Get handler caps.RegisterHandler( capsName, new RestStreamHandler( "GET", capsPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return GetEnvironmentSettings(request, path, param, agentID, caps); })); // Set handler caps.RegisterHandler( capsName, new RestStreamHandler( "POST", capsPath, delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { string result = SetEnvironmentSettings(request, path, param, agentID, caps); if (result == null) return string.Empty; return result; })); }
private string SetEnvironmentSettings(string request, string path, string param, UUID agentID, Caps caps) { LLSDEnvironmentSetResponse setResponse = new LLSDEnvironmentSetResponse(); m_log.WarnFormat("[{0}]: Environment POST handler for agentID {1}", Name, agentID); setResponse.regionID = regionID; setResponse.success = false; if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false)) { setResponse.fail_reason = "Insufficient estate permissions, settings has not been saved."; return LLSDHelpers.SerializeLLSDReply(setResponse); } try { m_scene.StorageManager.DataStore.StoreRegionEnvironmentString(regionID, request); setResponse.success = true; m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}", Name, agentID, caps.RegionName); } catch (Exception e) { m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}", Name, caps.RegionName, e.Message, e.StackTrace); setResponse.success = false; setResponse.fail_reason = String.Format("Environment Set for region {0} has failed, settings has not been saved.", caps.RegionName); } string response = LLSDHelpers.SerializeLLSDReply(setResponse); return response; }