本文整理汇总了C#中UUID.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# UUID.GetBytes方法的具体用法?C# UUID.GetBytes怎么用?C# UUID.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UUID
的用法示例。
在下文中一共展示了UUID.GetBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UUIDs
public void UUIDs()
{
// Creation
UUID a = new UUID();
byte[] bytes = a.GetBytes();
for (int i = 0; i < 16; i++)
Assert.IsTrue(bytes[i] == 0x00);
// Comparison
a = new UUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF }, 0);
UUID b = new UUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x0E, 0x0F }, 0);
Assert.IsTrue(a == b, "UUID comparison operator failed, " + a.ToString() + " should equal " +
b.ToString());
// From string
a = new UUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x0E, 0x0F }, 0);
string zeroonetwo = "00010203-0405-0607-0809-0a0b0c0d0e0f";
b = new UUID(zeroonetwo);
Assert.IsTrue(a == b, "UUID hyphenated string constructor failed, should have " + a.ToString() +
" but we got " + b.ToString());
// ToString()
Assert.IsTrue(a == b);
Assert.IsTrue(a == (UUID)zeroonetwo);
// TODO: CRC test
}
示例2: Agent
public Agent(UUID uuid, Scene scene)
{
this.uuid = uuid;
// Random passwords only work for single standalone regions.
// this.pass = "u" + UUID.Random().ToString().Replace("-", "").Substring(0, 16);
// This works for multiple regions and in grid mode, but it is not a safe password, because the
// password can be calculated based on the UUID. It is not advised to use such unsafe passwords.
this.pass = "u" + Convert.ToBase64String(uuid.GetBytes()).Replace('+', '-').Replace('/', '_').Substring(2, 16);
}
示例3: RenderMaterialsPostCap
public string RenderMaterialsPostCap(string request, UUID agentID)
{
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
OSDMap resp = new OSDMap();
OSDMap materialsFromViewer = null;
OSDArray respArr = new OSDArray();
if (req.ContainsKey("Zipped"))
{
OSD osd = null;
byte[] inBytes = req["Zipped"].AsBinary();
try
{
osd = ZDecompressBytesToOsd(inBytes);
if (osd != null)
{
if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
{
foreach (OSD elem in (OSDArray)osd)
{
try
{
UUID id = new UUID(elem.AsBinary(), 0);
lock (m_regionMaterials)
{
if (m_regionMaterials.ContainsKey(id))
{
OSDMap matMap = new OSDMap();
matMap["ID"] = OSD.FromBinary(id.GetBytes());
matMap["Material"] = m_regionMaterials[id];
respArr.Add(matMap);
}
else
{
m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());
// Theoretically we could try to load the material from the assets service,
// but that shouldn't be necessary because the viewer should only request
// materials that exist in a prim on the region, and all of these materials
// are already stored in m_regionMaterials.
}
}
}
catch (Exception e)
{
m_log.Error("Error getting materials in response to viewer request", e);
continue;
}
}
}
else if (osd is OSDMap) // request to assign a material
{
materialsFromViewer = osd as OSDMap;
if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
{
OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
if (matsOsd is OSDArray)
{
OSDArray matsArr = matsOsd as OSDArray;
try
{
foreach (OSDMap matsMap in matsArr)
{
uint primLocalID = 0;
try {
primLocalID = matsMap["ID"].AsUInteger();
}
catch (Exception e) {
m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
continue;
}
OSDMap mat = null;
try
{
mat = matsMap["Material"] as OSDMap;
}
catch (Exception e)
{
m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
continue;
}
SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
if (sop == null)
{
m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
continue;
}
if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
{
//.........这里部分代码省略.........
示例4: ProvisionVoiceAccountRequest
/// <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;
if (scene == null) throw new Exception("[VivoxVoice][PROVISIONVOICE] Invalid scene");
avatar = scene.GetScenePresence(agentID);
while (avatar == null)
{
Thread.Sleep(100);
avatar = scene.GetScenePresence(agentID);
}
avatarName = avatar.Name;
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;
//.........这里部分代码省略.........
示例5: nameFromID
private static string nameFromID(UUID id)
{
string result = null;
if (id == UUID.Zero)
return result;
// Prepending this apparently prevents conflicts with reserved names inside the vivox and diamondware code.
result = "x";
// Base64 encode and replace the pieces of base64 that are less compatible
// with e-mail local-parts.
// See RFC-4648 "Base 64 Encoding with URL and Filename Safe Alphabet"
byte[] encbuff = id.GetBytes();
result += Convert.ToBase64String(encbuff);
result = result.Replace('+', '-');
result = result.Replace('/', '_');
return result;
}
示例6: Name
public static string Name(UUID uuid)
{
return "x" + Convert.ToBase64String(uuid.GetBytes()).Replace('+', '-').Replace('/', '_');
}
示例7: BeamEffect
/// <summary>
/// Create a particle beam between an avatar and an primitive
/// </summary>
/// <param name="sourceAvatar">The ID of source avatar</param>
/// <param name="targetObject">The ID of the target primitive</param>
/// <param name="globalOffset">global offset</param>
/// <param name="color">A <see cref="Color4"/> object containing the combined red, green, blue and alpha
/// color values of particle beam</param>
/// <param name="duration">a float representing the duration the parcicle beam will last</param>
/// <param name="effectID">A Unique ID for the beam</param>
/// <seealso cref="ViewerEffectPacket"/>
public void BeamEffect(UUID sourceAvatar, UUID targetObject, Vector3d globalOffset, Color4 color,
float duration, UUID effectID)
{
ViewerEffectPacket effect = new ViewerEffectPacket();
effect.AgentData.AgentID = Client.Self.AgentID;
effect.AgentData.SessionID = Client.Self.SessionID;
effect.Effect = new ViewerEffectPacket.EffectBlock[1];
effect.Effect[0] = new ViewerEffectPacket.EffectBlock();
effect.Effect[0].AgentID = Client.Self.AgentID;
effect.Effect[0].Color = color.GetBytes();
effect.Effect[0].Duration = duration;
effect.Effect[0].ID = effectID;
effect.Effect[0].Type = (byte)EffectType.Beam;
byte[] typeData = new byte[56];
Buffer.BlockCopy(sourceAvatar.GetBytes(), 0, typeData, 0, 16);
Buffer.BlockCopy(targetObject.GetBytes(), 0, typeData, 16, 16);
Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24);
effect.Effect[0].TypeData = typeData;
Client.Network.SendPacket(effect);
}
示例8: PointAtEffect
/// <summary>
/// Start a particle stream between an agent and an object
/// </summary>
/// <param name="sourceAvatar"><seealso cref="UUID"/> Key of the source agent</param>
/// <param name="targetObject"><seealso cref="UUID"/> Key of the target object</param>
/// <param name="globalOffset"></param>
/// <param name="type">The type from the <seealso cref="T:PointAtType"/> enum</param>
/// <param name="effectID">A unique <seealso cref="UUID"/> for this effect</param>
public void PointAtEffect(UUID sourceAvatar, UUID targetObject, Vector3d globalOffset, PointAtType type,
UUID effectID)
{
ViewerEffectPacket effect = new ViewerEffectPacket();
effect.AgentData.AgentID = Client.Self.AgentID;
effect.AgentData.SessionID = Client.Self.SessionID;
effect.Effect = new ViewerEffectPacket.EffectBlock[1];
effect.Effect[0] = new ViewerEffectPacket.EffectBlock();
effect.Effect[0].AgentID = Client.Self.AgentID;
effect.Effect[0].Color = new byte[4];
effect.Effect[0].Duration = (type == PointAtType.Clear) ? 0.0f : Single.MaxValue / 4.0f;
effect.Effect[0].ID = effectID;
effect.Effect[0].Type = (byte)EffectType.PointAt;
byte[] typeData = new byte[57];
if (sourceAvatar != UUID.Zero)
Buffer.BlockCopy(sourceAvatar.GetBytes(), 0, typeData, 0, 16);
if (targetObject != UUID.Zero)
Buffer.BlockCopy(targetObject.GetBytes(), 0, typeData, 16, 16);
Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24);
typeData[56] = (byte)type;
effect.Effect[0].TypeData = typeData;
Client.Network.SendPacket(effect);
}
示例9: GiveFolder
/// <summary>
/// Give an inventory Folder with contents to another avatar
/// </summary>
/// <param name="folderID">The <seealso cref="UUID"/> of the Folder to give</param>
/// <param name="folderName">The name of the folder</param>
/// <param name="assetType">The type of the item from the <seealso cref="AssetType"/> enum</param>
/// <param name="recipient">The <seealso cref="UUID"/> of the recipient</param>
/// <param name="doEffect">true to generate a beameffect during transfer</param>
public void GiveFolder(UUID folderID, string folderName, AssetType assetType, UUID recipient,
bool doEffect)
{
byte[] bucket;
List<InventoryItem> folderContents = new List<InventoryItem>();
Client.Inventory.FolderContents(folderID, Client.Self.AgentID, false, true, InventorySortOrder.ByDate, 1000 * 15).ForEach(
delegate(InventoryBase ib)
{
folderContents.Add(Client.Inventory.FetchItem(ib.UUID, Client.Self.AgentID, 1000 * 10));
});
bucket = new byte[17 * (folderContents.Count + 1)];
//Add parent folder (first item in bucket)
bucket[0] = (byte)assetType;
Buffer.BlockCopy(folderID.GetBytes(), 0, bucket, 1, 16);
//Add contents to bucket after folder
for (int i = 1; i <= folderContents.Count; ++i)
{
bucket[i * 17] = (byte)folderContents[i - 1].AssetType;
Buffer.BlockCopy(folderContents[i - 1].UUID.GetBytes(), 0, bucket, i * 17 + 1, 16);
}
Client.Self.InstantMessage(
Client.Self.Name,
recipient,
folderName,
UUID.Random(),
InstantMessageDialog.InventoryOffered,
InstantMessageOnline.Online,
Client.Self.SimPosition,
Client.Network.CurrentSim.ID,
bucket);
if (doEffect)
{
Client.Self.BeamEffect(Client.Self.AgentID, recipient, Vector3d.Zero,
Client.Settings.DEFAULT_EFFECT_COLOR, 1f, UUID.Random());
}
}
示例10: GiveFolder
public void GiveFolder(UUID folderID, string folderName, AssetType assetType, UUID recipient,
bool doEffect, ICollection<ItemData> folderContents)
{
byte[] bucket;
bucket = new byte[17 * (folderContents.Count + 1)];
//Add parent folder (first item in bucket)
bucket[0] = (byte)assetType;
Buffer.BlockCopy(folderID.GetBytes(), 0, bucket, 1, 16);
//Add contents to bucket after folder
int index = 1;
foreach (ItemData item in folderContents)
{
bucket[index * 17] = (byte)item.AssetType;
Buffer.BlockCopy(item.UUID.GetBytes(), 0, bucket, index * 17 + 1, 16);
++index;
}
_Agents.InstantMessage(
_Agents.Name,
recipient,
folderName,
UUID.Random(),
InstantMessageDialog.InventoryOffered,
InstantMessageOnline.Online,
_Agents.SimPosition,
_Network.CurrentSim.ID,
bucket);
if (doEffect)
{
_Agents.BeamEffect(_Agents.AgentID, recipient, Vector3d.Zero,
_Client.Settings.DEFAULT_EFFECT_COLOR, 1f, UUID.Random());
}
}
示例11: GiveItem
/// <summary>
/// Give an inventory item to another avatar
/// </summary>
/// <param name="itemID">The <seealso cref="UUID"/> of the item to give</param>
/// <param name="itemName">The name of the item</param>
/// <param name="assetType">The type of the item from the <seealso cref="AssetType"/> enum</param>
/// <param name="recipient">The <seealso cref="UUID"/> of the recipient</param>
/// <param name="doEffect">true to generate a beameffect during transfer</param>
public void GiveItem(UUID itemID, string itemName, AssetType assetType, UUID recipient,
bool doEffect)
{
byte[] bucket;
bucket = new byte[17];
bucket[0] = (byte)assetType;
Buffer.BlockCopy(itemID.GetBytes(), 0, bucket, 1, 16);
Client.Self.InstantMessage(
Client.Self.Name,
recipient,
itemName,
UUID.Random(),
InstantMessageDialog.InventoryOffered,
InstantMessageOnline.Online,
Client.Self.SimPosition,
Client.Network.CurrentSim.ID,
bucket);
if (doEffect)
{
Client.Self.BeamEffect(Client.Self.AgentID, recipient, Vector3d.Zero,
Client.Settings.DEFAULT_EFFECT_COLOR, 1f, UUID.Random());
}
// Remove from store if the item is no copy
if (Store.Items.ContainsKey(itemID) && Store[itemID] is InventoryItem)
{
InventoryItem invItem = (InventoryItem)Store[itemID];
if ((invItem.Permissions.OwnerMask & PermissionMask.Copy) == PermissionMask.None)
{
Store.RemoveNodeFor(invItem);
}
}
}
示例12: ProvisionVoiceAccountRequest
/// <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(IScene scene, string request, string path, string param,
UUID agentID)
{
IScenePresence 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 = "1234";//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);
}
}
OSDMap map = new OSDMap();
map["username"] = agentname;
map["password"] = password;
map["voice_sip_uri_hostname"] = m_freeSwitchRealm;
map["voice_account_server_name"] = String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress,
m_freeSwitchServicePort, m_freeSwitchAPIPrefix);
string r = OSDParser.SerializeLLSDXmlString(map);
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>";
}
}
示例13: PackUUID
/// <summary>
///
/// </summary>
/// <param name="data"></param>
public void PackUUID(UUID data)
{
byte[] bytes = data.GetBytes();
// Not sure if our PackBitArray function can handle 128-bit byte
//arrays, so using this for now
for (int i = 0; i < 16; i++)
PackBits(bytes[i], 8);
}
示例14: sendParticleCircle
public void sendParticleCircle(UUID who, float dur)
{
ViewerEffectPacket p = new ViewerEffectPacket();
p.AgentData = new ViewerEffectPacket.AgentDataBlock();
p.AgentData.AgentID = rc.plugin.frame.AgentID;
p.AgentData.SessionID = rc.plugin.frame.SessionID;
p.Effect = new ViewerEffectPacket.EffectBlock[1];
p.Effect[0] = new ViewerEffectPacket.EffectBlock();
p.Effect[0].AgentID = rc.plugin.frame.AgentID;
p.Effect[0].Duration = dur;
p.Effect[0].ID = UUID.Random();
p.Effect[0].Type = (byte)7;
p.Effect[0].TypeData= new byte[56];
Buffer.BlockCopy(who.GetBytes(),0,p.Effect[0].TypeData,0,16);
Buffer.BlockCopy(UUID.Zero.GetBytes(),0,p.Effect[0].TypeData,16,16);
Buffer.BlockCopy(Vector3d.Zero.GetBytes(), 0, p.Effect[0].TypeData, 32, 24);
p.Header.Reliable = true;
p.Effect[0].Color = new byte[4];
Buffer.BlockCopy(
rc.plugin.SharedInfo.rainbow[colorIndex], 0, p.Effect[0].Color, 0, 4);
rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);
rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);
}
示例15: GiveItem
/// <summary>
/// Give an inventory item to another avatar
/// </summary>
/// <param name="itemID">The <seealso cref="UUID"/> of the item to give</param>
/// <param name="itemName">The name of the item</param>
/// <param name="assetType">The type of the item from the <seealso cref="AssetType"/> enum</param>
/// <param name="recipient">The <seealso cref="UUID"/> of the recipient</param>
/// <param name="doEffect">true to generate a beameffect during transfer</param>
public void GiveItem(UUID itemID, string itemName, AssetType assetType, UUID recipient,
bool doEffect)
{
byte[] bucket;
bucket = new byte[17];
bucket[0] = (byte)assetType;
Buffer.BlockCopy(itemID.GetBytes(), 0, bucket, 1, 16);
_Self.InstantMessage(
_Self.Name,
recipient,
itemName,
UUID.Random(),
InstantMessageDialog.InventoryOffered,
InstantMessageOnline.Online,
_Self.SimPosition,
_Network.CurrentSim.ID,
bucket);
if (doEffect)
{
_Self.BeamEffect(_Network.AgentID, recipient, Vector3d.Zero,
DefaultEffectColor, 1f, UUID.Random());
}
}