本文整理汇总了C#中OpenMetaverse.Http.CapsClient.GetResponse方法的典型用法代码示例。如果您正苦于以下问题:C# CapsClient.GetResponse方法的具体用法?C# CapsClient.GetResponse怎么用?C# CapsClient.GetResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenMetaverse.Http.CapsClient
的用法示例。
在下文中一共展示了CapsClient.GetResponse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetParcelResouces
/// <summary>
/// Retrieves information on resources used by the parcel
/// </summary>
/// <param name="parcelID">UUID of the parcel</param>
/// <param name="getDetails">Should per object resource usage be requested</param>
/// <param name="callback">Callback invoked when the request is complete</param>
public void GetParcelResouces(UUID parcelID, bool getDetails, LandResourcesCallback callback)
{
try
{
Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("LandResources");
CapsClient request = new CapsClient(url);
request.OnComplete += delegate(CapsClient client, OSD result, Exception error)
{
try
{
if (result == null || error != null)
{
callback(false, null);
}
LandResourcesMessage response = new LandResourcesMessage();
response.Deserialize((OSDMap)result);
CapsClient summaryRequest = new CapsClient(response.ScriptResourceSummary);
OSD summaryResponse = summaryRequest.GetResponse(Client.Settings.CAPS_TIMEOUT);
LandResourcesInfo res = new LandResourcesInfo();
res.Deserialize((OSDMap)summaryResponse);
if (response.ScriptResourceDetails != null && getDetails)
{
CapsClient detailRequest = new CapsClient(response.ScriptResourceDetails);
OSD detailResponse = detailRequest.GetResponse(Client.Settings.CAPS_TIMEOUT);
res.Deserialize((OSDMap)detailResponse);
}
callback(true, res);
}
catch (Exception ex)
{
Logger.Log("Failed fetching land resources", Helpers.LogLevel.Error, Client, ex);
callback(false, null);
}
};
LandResourcesRequest param = new LandResourcesRequest();
param.ParcelID = parcelID;
request.BeginGetResponse(param.Serialize(), OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);
}
catch (Exception ex)
{
Logger.Log("Failed fetching land resources:", Helpers.LogLevel.Error, Client, ex);
callback(false, null);
}
}
示例2: RequestRemoteParcelID
/// <summary>
/// Requests the UUID of the parcel in a remote region at a specified location
/// </summary>
/// <param name="location">Location of the parcel in the remote region</param>
/// <param name="regionHandle">Remote region handle</param>
/// <param name="regionID">Remote region UUID</param>
/// <returns>If successful UUID of the remote parcel, UUID.Zero otherwise</returns>
public UUID RequestRemoteParcelID(Vector3 location, ulong regionHandle, UUID regionID)
{
Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("RemoteParcelRequest");
if (url != null)
{
RemoteParcelRequestRequest msg = new RemoteParcelRequestRequest();
msg.Location = location;
msg.RegionHandle = regionHandle;
msg.RegionID = regionID;
try
{
CapsClient request = new CapsClient(url);
OSD result = request.GetResponse(msg.Serialize(), OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);
RemoteParcelRequestReply response = new RemoteParcelRequestReply();
response.Deserialize((OSDMap)result);
return response.ParcelID;
}
catch (Exception)
{
Logger.Log("Failed to fetch remote parcel ID", Helpers.LogLevel.Debug, Client);
}
}
return UUID.Zero;
}
示例3: Store
public string Store(AssetBase asset)
{
if (asset.Temporary || asset.Local)
{
if (m_Cache != null)
m_Cache.Cache(asset);
else
m_log.Warn("[CABLE BEACH ASSETS]: Cache is missing. A valid cache must be configured for proper operation");
return asset.ID;
}
if (m_WorldServiceConnector != null)
{
// Cache the asset first
if (m_Cache != null)
m_Cache.Cache(asset);
// FIXME: OpenSim API needs to be fixed to pass this in wherever possible
UUID userID = UUID.Zero;
Uri createAssetUri = GetServiceCapability(userID, CableBeachServices.ASSET_CREATE_ASSET);
if (createAssetUri != null)
{
UUID assetID;
UUID.TryParse(asset.Metadata.ID, out assetID);
CreateAssetMessage create = new CreateAssetMessage();
create.Metadata = new MetadataDefault();
// Convert the OpenSim Type enum to a content-type if it is set, or try to use the OpenSim ContentType field
sbyte assetType = asset.Metadata.Type;
if (assetType != -1)
{
create.Metadata.ContentType = CableBeachUtils.SLAssetTypeToContentType(assetType);
}
else if (!String.IsNullOrEmpty(asset.Metadata.ContentType))
{
create.Metadata.ContentType = asset.Metadata.ContentType;
}
else
{
m_log.Warn("[CABLE BEACH ASSETS]: Storing asset " + assetID + " with a content-type of application/octet-stream");
create.Metadata.ContentType = "application/octet-stream";
}
create.Metadata.CreationDate = DateTime.Now;
create.Metadata.Description = asset.Metadata.Description;
create.Metadata.ID = assetID;
create.Metadata.Methods = new Dictionary<string, Uri>();
create.Metadata.Name = asset.Metadata.Name;
create.Metadata.SHA256 = OpenMetaverse.Utils.EmptyBytes;
create.Metadata.Temporary = asset.Metadata.Temporary;
create.Base64Data = Convert.ToBase64String(asset.Data);
CapsClient request = new CapsClient(createAssetUri);
OSDMap response = request.GetResponse(create.Serialize(), OSDFormat.Json, REQUEST_TIMEOUT) as OSDMap;
if (response != null)
{
// Parse the response
CreateAssetReplyMessage reply = new CreateAssetReplyMessage();
reply.Deserialize(response);
if (reply.AssetID != UUID.Zero)
{
asset.FullID = reply.AssetID;
asset.ID = reply.AssetID.ToString();
return asset.ID;
}
}
else
{
m_log.Error("[CABLE BEACH ASSETS]: Failed to store asset at " + createAssetUri);
}
}
else
{
m_log.Warn("[CABLE BEACH ASSETS]: Failed to store remote asset " + asset.ID + ", could not find a create_asset capability");
}
}
else
{
m_log.Error("[CABLE BEACH ASSETS]: Cannot upload asset, no reference to a world server connector");
}
return String.Empty;
}
示例4: UpdateAvatarAppearance
/// <summary>
/// Initate server baking process
/// </summary>
/// <returns>True if the server baking was successful</returns>
private bool UpdateAvatarAppearance()
{
Caps caps = Client.Network.CurrentSim.Caps;
if (caps == null)
{
return false;
}
Uri url = caps.CapabilityURI("UpdateAvatarAppearance");
if (url == null)
{
return false;
}
InventoryFolder COF = GetCOF();
if (COF == null)
{
return false;
}
else
{
// TODO: create Current Outfit Folder
}
CapsClient capsRequest = new CapsClient(url);
OSDMap request = new OSDMap(1);
request["cof_version"] = COF.Version;
string msg = "Setting server side baking failed";
OSD res = capsRequest.GetResponse(request, OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT * 2);
if (res != null && res is OSDMap)
{
OSDMap result = (OSDMap)res;
if (result["success"])
{
Logger.Log("Successfully set appearance", Helpers.LogLevel.Info, Client);
// TODO: Set local visual params and baked textures based on the result here
return true;
}
else
{
if (result.ContainsKey("error"))
{
msg += ": " + result["error"].AsString();
}
}
}
Logger.Log(msg, Helpers.LogLevel.Error, Client);
return false;
}
示例5: GetMetadata
public AssetMetadata GetMetadata(string id)
{
// Cache check
if (m_Cache != null)
{
AssetBase asset = m_Cache.Get(id);
if (asset != null)
return asset.Metadata;
}
AssetMetadata metadata = null;
Uri assetMetadataUri = GetAssetUri(id, "metadata");
// Remote metadata request
CapsClient request = new CapsClient(assetMetadataUri);
OSDMap responseMap = request.GetResponse(REQUEST_TIMEOUT) as OSDMap;
if (responseMap != null)
{
// Parse the response
GetAssetMetadataMessage message = new GetAssetMetadataMessage();
message.Deserialize(responseMap);
metadata = new AssetMetadata();
metadata.ContentType = message.Metadata.ContentType;
metadata.CreationDate = message.Metadata.CreationDate;
metadata.Description = message.Metadata.Description;
metadata.FullID = message.Metadata.ID;
metadata.ID = id;
metadata.Local = false;
metadata.Name = message.Metadata.Name;
metadata.SHA1 = Utils.EmptyBytes; //message.Metadata.SHA256; // FIXME: :-(
metadata.Temporary = message.Metadata.Temporary;
metadata.Type = (sbyte)CableBeachUtils.ContentTypeToSLAssetType(message.Metadata.ContentType);
}
else
{
m_log.Debug("[CABLE BEACH ASSETS]: Failed to fetch asset metadata from " + assetMetadataUri);
}
return metadata;
}