private void RouteRemoteCapability(Capability cap, IHttpClientContext context, IHttpRequest request, IHttpResponse response) { // TODO: Proxy IHttpRequest to a new HttpWebRequest pointing at cap.Resource throw new NotImplementedException(); }
/// <summary> /// Create a one-time capability mapping to a protected callback /// resource /// </summary> /// <param name="ownerID">Capability owner</param> /// <param name="sendResponseAfterCallback">Set this to false to leave /// the connection open after the capability has been routed. Useful /// for event queue capabilities</param> /// <param name="resource">Protected one-time resource to map to</param> /// <returns>Absolute URL of the capability</returns> public Uri AddOneTimeCapability(UUID ownerID, bool sendResponseAfterCallback, CapabilityCallback resource) { Capability cap = null; Dictionary<string, Capability> ownerCaps; m_capSyncRoot.EnterWriteLock(); try { // Check if this ownerID has any capabilities yet if (!m_ownerCapabilities.TryGetValue(ownerID, out ownerCaps)) { ownerCaps = new Dictionary<string, Capability>(); m_ownerCapabilities[ownerID] = ownerCaps; } // Create the one-time capability cap = new Capability(UUID.Random(), ownerID, resource, sendResponseAfterCallback); // Add this capability to the capabilities collection m_capabilities[cap.ID] = cap; // Add this capability to the list of capabilities owned by ownerID ownerCaps[cap.Resource] = cap; } finally { m_capSyncRoot.ExitWriteLock(); } return new Uri(m_capBaseUrl + cap.ID.ToString(), UriKind.Absolute); }
private void RouteLocalCapability(Capability cap, CapabilityCallback callback, IHttpClientContext context, IHttpRequest request, IHttpResponse response) { callback(cap, context, request, response); if (cap.SendResponseAfterCallback && !response.Sent) { try { response.Send(); } catch (Exception ex) { m_log.ErrorFormat("Failed to send HTTP response for request to capability {0}: {1}", request.Uri, ex.Message); } } }
/// <summary> /// Create a capability mapping to a protected resource /// </summary> /// <param name="ownerID">Capability owner</param> /// <param name="sendResponseAfterCallback">Set this to false to leave /// the connection open after the capability has been routed. Useful /// for event queue capabilities</param> /// <param name="resourceOwnerID">Owner of the protected resource, such /// as a scene ID</param> /// <param name="resource">Protected resource to map to</param> /// <returns>Absolute URL of the capability</returns> public Uri AddCapability(UUID ownerID, bool sendResponseAfterCallback, UUID resourceOwnerID, string resource) { resource = resourceOwnerID.ToString() + "/" + resource; Capability cap = null; Dictionary<string, Capability> ownerCaps; m_capSyncRoot.EnterWriteLock(); try { // Check if this ownerID has any capabilities yet if (!m_ownerCapabilities.TryGetValue(ownerID, out ownerCaps)) { ownerCaps = new Dictionary<string, Capability>(); m_ownerCapabilities[ownerID] = ownerCaps; } if (!ownerCaps.TryGetValue(resource, out cap)) { // Capability doesn't exist yet, create it cap = new Capability(UUID.Random(), ownerID, resource, sendResponseAfterCallback); // Add this capability to the capabilities collection m_capabilities[cap.ID] = cap; // Add this capability to the list of capabilities owned by ownerID ownerCaps[resource] = cap; } } finally { m_capSyncRoot.ExitWriteLock(); } return new Uri(m_capBaseUrl + cap.ID.ToString(), UriKind.Absolute); }