mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 14:16:07 +08:00
change encoding of event cap messages
This commit is contained in:
@@ -41,40 +41,23 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
{
|
||||
private EventQueueHelper() {} // no construction possible, it's an utility class
|
||||
|
||||
public static byte[] ulongToByteArray(ulong uLongValue)
|
||||
{
|
||||
// Reverse endianness of RegionHandle
|
||||
return new byte[8]
|
||||
{
|
||||
(byte)((uLongValue >> 56) & 0xff),
|
||||
(byte)((uLongValue >> 48) & 0xff),
|
||||
(byte)((uLongValue >> 40) & 0xff),
|
||||
(byte)((uLongValue >> 32) & 0xff),
|
||||
(byte)((uLongValue >> 24) & 0xff),
|
||||
(byte)((uLongValue >> 16) & 0xff),
|
||||
(byte)((uLongValue >> 8) & 0xff),
|
||||
(byte)(uLongValue & 0xff)
|
||||
};
|
||||
}
|
||||
|
||||
public static StringBuilder StartEvent(string eventName)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
LLSDxmlEncode.AddMap(sb);
|
||||
LLSDxmlEncode.AddElem("message", eventName, sb);
|
||||
LLSDxmlEncode.AddMap("body", sb);
|
||||
LLSDxmlEncode.AddMap("body", sb);
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
public static string EndEvent(StringBuilder sb)
|
||||
{
|
||||
LLSDxmlEncode.AddEndMap(sb); // close body
|
||||
LLSDxmlEncode.AddEndMap(sb); // close body
|
||||
LLSDxmlEncode.AddEndMap(sb); // close event
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
public static OSD BuildEvent(string eventName, OSD eventBody)
|
||||
{
|
||||
OSDMap llsdEvent = new OSDMap(2);
|
||||
@@ -84,137 +67,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
return llsdEvent;
|
||||
}
|
||||
|
||||
public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint, int regionSizeX, int regionSizeY)
|
||||
{
|
||||
OSDMap llsdSimInfo = new OSDMap(5);
|
||||
|
||||
llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle)));
|
||||
llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes()));
|
||||
llsdSimInfo.Add("Port", OSD.FromInteger(endPoint.Port));
|
||||
llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX));
|
||||
llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY));
|
||||
|
||||
OSDArray arr = new OSDArray(1);
|
||||
arr.Add(llsdSimInfo);
|
||||
|
||||
OSDMap llsdBody = new OSDMap(1);
|
||||
llsdBody.Add("SimulatorInfo", arr);
|
||||
|
||||
return BuildEvent("EnableSimulator", llsdBody);
|
||||
}
|
||||
/*
|
||||
public static OSD DisableSimulator(ulong handle)
|
||||
{
|
||||
//OSDMap llsdSimInfo = new OSDMap(1);
|
||||
|
||||
//llsdSimInfo.Add("Handle", new OSDBinary(regionHandleToByteArray(handle)));
|
||||
|
||||
//OSDArray arr = new OSDArray(1);
|
||||
//arr.Add(llsdSimInfo);
|
||||
|
||||
OSDMap llsdBody = new OSDMap(0);
|
||||
//llsdBody.Add("SimulatorInfo", arr);
|
||||
|
||||
return BuildEvent("DisableSimulator", llsdBody);
|
||||
}
|
||||
*/
|
||||
public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt,
|
||||
IPEndPoint newRegionExternalEndPoint,
|
||||
string capsURL, UUID agentID, UUID sessionID,
|
||||
int regionSizeX, int regionSizeY)
|
||||
{
|
||||
OSDArray lookAtArr = new OSDArray(3);
|
||||
lookAtArr.Add(OSD.FromReal(lookAt.X));
|
||||
lookAtArr.Add(OSD.FromReal(lookAt.Y));
|
||||
lookAtArr.Add(OSD.FromReal(lookAt.Z));
|
||||
|
||||
OSDArray positionArr = new OSDArray(3);
|
||||
positionArr.Add(OSD.FromReal(pos.X));
|
||||
positionArr.Add(OSD.FromReal(pos.Y));
|
||||
positionArr.Add(OSD.FromReal(pos.Z));
|
||||
|
||||
OSDMap infoMap = new OSDMap(2);
|
||||
infoMap.Add("LookAt", lookAtArr);
|
||||
infoMap.Add("Position", positionArr);
|
||||
|
||||
OSDArray infoArr = new OSDArray(1);
|
||||
infoArr.Add(infoMap);
|
||||
|
||||
OSDMap agentDataMap = new OSDMap(2);
|
||||
agentDataMap.Add("AgentID", OSD.FromUUID(agentID));
|
||||
agentDataMap.Add("SessionID", OSD.FromUUID(sessionID));
|
||||
|
||||
OSDArray agentDataArr = new OSDArray(1);
|
||||
agentDataArr.Add(agentDataMap);
|
||||
|
||||
OSDMap regionDataMap = new OSDMap(6);
|
||||
regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle)));
|
||||
regionDataMap.Add("SeedCapability", OSD.FromString(capsURL));
|
||||
regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes()));
|
||||
regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port));
|
||||
regionDataMap.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX));
|
||||
regionDataMap.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY));
|
||||
|
||||
OSDArray regionDataArr = new OSDArray(1);
|
||||
regionDataArr.Add(regionDataMap);
|
||||
|
||||
OSDMap llsdBody = new OSDMap(3);
|
||||
llsdBody.Add("Info", infoArr);
|
||||
llsdBody.Add("AgentData", agentDataArr);
|
||||
llsdBody.Add("RegionData", regionDataArr);
|
||||
|
||||
return BuildEvent("CrossedRegion", llsdBody);
|
||||
}
|
||||
|
||||
public static OSD TeleportFinishEvent(
|
||||
ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
|
||||
uint locationID, uint flags, string capsURL, UUID agentID,
|
||||
int regionSizeX, int regionSizeY)
|
||||
{
|
||||
// not sure why flags get overwritten here
|
||||
if ((flags & (uint)TeleportFlags.IsFlying) != 0)
|
||||
flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying;
|
||||
else
|
||||
flags = (uint)TeleportFlags.ViaLocation;
|
||||
|
||||
OSDMap info = new OSDMap();
|
||||
info.Add("AgentID", OSD.FromUUID(agentID));
|
||||
info.Add("LocationID", OSD.FromInteger(4)); // TODO what is this?
|
||||
info.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(regionHandle)));
|
||||
info.Add("SeedCapability", OSD.FromString(capsURL));
|
||||
info.Add("SimAccess", OSD.FromInteger(simAccess));
|
||||
info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes()));
|
||||
info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port));
|
||||
// info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation
|
||||
info.Add("TeleportFlags", OSD.FromUInteger(flags));
|
||||
info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX));
|
||||
info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY));
|
||||
|
||||
OSDArray infoArr = new OSDArray();
|
||||
infoArr.Add(info);
|
||||
|
||||
OSDMap body = new OSDMap();
|
||||
body.Add("Info", infoArr);
|
||||
|
||||
return BuildEvent("TeleportFinish", body);
|
||||
}
|
||||
|
||||
public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap,
|
||||
ulong regionHandle, int regionSizeX, int regionSizeY)
|
||||
{
|
||||
OSDMap body = new OSDMap(6)
|
||||
{
|
||||
{"agent-id", new OSDUUID(agentID)},
|
||||
{"sim-ip-and-port", new OSDString(simIpAndPort)},
|
||||
{"seed-capability", new OSDString(seedcap)},
|
||||
{"region-handle", OSD.FromULong(regionHandle)},
|
||||
{"region-size-x", OSD.FromUInteger((uint)regionSizeX)},
|
||||
{"region-size-y", OSD.FromUInteger((uint)regionSizeY)}
|
||||
};
|
||||
|
||||
return BuildEvent("EstablishAgentCommunication", body);
|
||||
}
|
||||
|
||||
public static OSD KeepAliveEvent()
|
||||
{
|
||||
return BuildEvent("FAKEEVENT", new OSDMap());
|
||||
@@ -261,7 +113,33 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
messageParams.Add("ttl", new OSDInteger((int)ttl));
|
||||
messageParams.Add("from_id", new OSDUUID(fromAgent));
|
||||
messageParams.Add("from_group", new OSDInteger(fromGroup ? 1 : 0));
|
||||
/*
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
LLSDxmlEncode.AddMap(sb); //messageParams
|
||||
|
||||
LLSDxmlEncode.AddElem("type", dialog, sb);
|
||||
LLSDxmlEncode.AddElem("position", position, sb);
|
||||
LLSDxmlEncode.AddElem("region_id", UUID.Zero, sb);
|
||||
LLSDxmlEncode.AddElem("to_id", toAgent, sb);
|
||||
LLSDxmlEncode.AddElem("source", 0, sb);
|
||||
|
||||
LLSDxmlEncode.AddMap("data", sb); //messageParams data
|
||||
LLSDxmlEncode.AddElem("binary_bucket", binaryBucket, sb);
|
||||
LLSDxmlEncode.AddEndMap(sb); //messageParams data
|
||||
|
||||
LLSDxmlEncode.AddElem("message", message, sb);
|
||||
LLSDxmlEncode.AddElem("id", transactionID, sb);
|
||||
LLSDxmlEncode.AddElem("from_name", fromName, sb);
|
||||
LLSDxmlEncode.AddElem("timestamp", timeStamp, sb);
|
||||
LLSDxmlEncode.AddElem("offline", (offline ? 1 : 0), sb);
|
||||
LLSDxmlEncode.AddElem("parent_estate_id", parentEstateID, sb);
|
||||
LLSDxmlEncode.AddElem("ttl", (int)ttl, sb);
|
||||
LLSDxmlEncode.AddElem("from_id", fromAgent, sb);
|
||||
LLSDxmlEncode.AddElem("from_group",fromGroup, sb);
|
||||
|
||||
LLSDxmlEncode.AddEndMap(sb); //messageParams
|
||||
string tt = sb.ToString();
|
||||
*/
|
||||
return messageParams;
|
||||
}
|
||||
|
||||
@@ -349,42 +227,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
return chatterBoxForceClose;
|
||||
}
|
||||
|
||||
public static OSD GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data)
|
||||
{
|
||||
OSDArray AgentData = new OSDArray(1);
|
||||
OSDMap AgentDataMap = new OSDMap(1);
|
||||
AgentDataMap.Add("AgentID", OSD.FromUUID(receiverAgent));
|
||||
AgentData.Add(AgentDataMap);
|
||||
|
||||
OSDArray GroupData = new OSDArray(data.Length);
|
||||
OSDArray NewGroupData = new OSDArray(data.Length);
|
||||
|
||||
foreach (GroupMembershipData membership in data)
|
||||
{
|
||||
OSDMap GroupDataMap = new OSDMap(6);
|
||||
OSDMap NewGroupDataMap = new OSDMap(1);
|
||||
|
||||
GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID));
|
||||
GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers));
|
||||
GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices));
|
||||
GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture));
|
||||
GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution));
|
||||
GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName));
|
||||
NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile));
|
||||
|
||||
GroupData.Add(GroupDataMap);
|
||||
NewGroupData.Add(NewGroupDataMap);
|
||||
}
|
||||
|
||||
OSDMap llDataStruct = new OSDMap(3);
|
||||
llDataStruct.Add("AgentData", AgentData);
|
||||
llDataStruct.Add("GroupData", GroupData);
|
||||
llDataStruct.Add("NewGroupData", NewGroupData);
|
||||
|
||||
return BuildEvent("AgentGroupDataUpdate", llDataStruct);
|
||||
|
||||
}
|
||||
|
||||
public static OSD PlacesQuery(PlacesReplyPacket PlacesReply)
|
||||
{
|
||||
OSDMap placesReply = new OSDMap();
|
||||
@@ -426,35 +268,5 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
|
||||
return placesReply;
|
||||
}
|
||||
|
||||
public static OSD ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage)
|
||||
{
|
||||
OSDMap message = new OSDMap();
|
||||
message.Add("message", OSD.FromString("ParcelProperties"));
|
||||
OSD message_body = parcelPropertiesMessage.Serialize();
|
||||
message.Add("body", message_body);
|
||||
return message;
|
||||
}
|
||||
|
||||
public static OSD partPhysicsProperties(uint localID, byte physhapetype,
|
||||
float density, float friction, float bounce, float gravmod)
|
||||
{
|
||||
|
||||
OSDMap physinfo = new OSDMap(6);
|
||||
physinfo["LocalID"] = localID;
|
||||
physinfo["Density"] = density;
|
||||
physinfo["Friction"] = friction;
|
||||
physinfo["GravityMultiplier"] = gravmod;
|
||||
physinfo["Restitution"] = bounce;
|
||||
physinfo["PhysicsShapeType"] = (int)physhapetype;
|
||||
|
||||
OSDArray array = new OSDArray(1);
|
||||
array.Add(physinfo);
|
||||
|
||||
OSDMap llsdBody = new OSDMap(1);
|
||||
llsdBody.Add("ObjectData", array);
|
||||
|
||||
return BuildEvent("ObjectPhysicsProperties", llsdBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user