31 using OpenMetaverse.Packets;
32 using OpenMetaverse.StructuredData;
33 using OpenMetaverse.Messages.Linden;
35 namespace OpenSim.
Region.ClientStack.Linden
41 private static byte[] ulongToByteArray(ulong uLongValue)
46 (byte)((uLongValue >> 56) % 256),
47 (byte)((uLongValue >> 48) % 256),
48 (byte)((uLongValue >> 40) % 256),
49 (byte)((uLongValue >> 32) % 256),
50 (byte)((uLongValue >> 24) % 256),
51 (byte)((uLongValue >> 16) % 256),
52 (byte)((uLongValue >> 8) % 256),
53 (byte)(uLongValue % 256)
67 llsdEvent.Add(
"message",
new OSDString(eventName));
68 llsdEvent.Add(
"body", eventBody);
73 public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint,
int regionSizeX,
int regionSizeY)
77 llsdSimInfo.Add(
"Handle",
new OSDBinary(ulongToByteArray(handle)));
78 llsdSimInfo.Add(
"IP",
new OSDBinary(endPoint.Address.GetAddressBytes()));
79 llsdSimInfo.Add(
"Port", OSD.FromInteger(endPoint.Port));
80 llsdSimInfo.Add(
"RegionSizeX", OSD.FromUInteger((uint)regionSizeX));
81 llsdSimInfo.Add(
"RegionSizeY", OSD.FromUInteger((uint)regionSizeY));
87 llsdBody.Add(
"SimulatorInfo", arr);
89 return BuildEvent(
"EnableSimulator", llsdBody);
104 return BuildEvent(
"DisableSimulator", llsdBody);
108 IPEndPoint newRegionExternalEndPoint,
109 string capsURL, UUID agentID, UUID sessionID,
110 int regionSizeX,
int regionSizeY)
113 lookAtArr.Add(OSD.FromReal(lookAt.X));
114 lookAtArr.Add(OSD.FromReal(lookAt.Y));
115 lookAtArr.Add(OSD.FromReal(lookAt.Z));
118 positionArr.Add(OSD.FromReal(pos.X));
119 positionArr.Add(OSD.FromReal(pos.Y));
120 positionArr.Add(OSD.FromReal(pos.Z));
123 infoMap.Add(
"LookAt", lookAtArr);
124 infoMap.Add(
"Position", positionArr);
127 infoArr.Add(infoMap);
130 agentDataMap.Add(
"AgentID", OSD.FromUUID(agentID));
131 agentDataMap.Add(
"SessionID", OSD.FromUUID(sessionID));
134 agentDataArr.Add(agentDataMap);
137 regionDataMap.Add(
"RegionHandle", OSD.FromBinary(ulongToByteArray(handle)));
138 regionDataMap.Add(
"SeedCapability", OSD.FromString(capsURL));
139 regionDataMap.Add(
"SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes()));
140 regionDataMap.Add(
"SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port));
141 regionDataMap.Add(
"RegionSizeX", OSD.FromUInteger((uint)regionSizeX));
142 regionDataMap.Add(
"RegionSizeY", OSD.FromUInteger((uint)regionSizeY));
145 regionDataArr.Add(regionDataMap);
148 llsdBody.Add(
"Info", infoArr);
149 llsdBody.Add(
"AgentData", agentDataArr);
150 llsdBody.Add(
"RegionData", regionDataArr);
152 return BuildEvent(
"CrossedRegion", llsdBody);
156 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
157 uint locationID, uint flags,
string capsURL, UUID agentID,
158 int regionSizeX,
int regionSizeY)
162 flags = (uint)
TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying;
167 info.Add(
"AgentID", OSD.FromUUID(agentID));
168 info.Add(
"LocationID", OSD.FromInteger(4));
169 info.Add(
"RegionHandle", OSD.FromBinary(ulongToByteArray(regionHandle)));
170 info.Add(
"SeedCapability", OSD.FromString(capsURL));
171 info.Add(
"SimAccess", OSD.FromInteger(simAccess));
172 info.Add(
"SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes()));
173 info.Add(
"SimPort", OSD.FromInteger(regionExternalEndPoint.Port));
175 info.Add(
"TeleportFlags", OSD.FromUInteger(flags));
176 info.Add(
"RegionSizeX", OSD.FromUInteger((uint)regionSizeX));
177 info.Add(
"RegionSizeY", OSD.FromUInteger((uint)regionSizeY));
183 body.Add(
"Info", infoArr);
185 return BuildEvent(
"TeleportFinish", body);
191 script.Add(
"ObjectID", OSD.FromUUID(objectID));
192 script.Add(
"ItemID", OSD.FromUUID(itemID));
193 script.Add(
"Running", OSD.FromBoolean(running));
194 script.Add(
"Mono", OSD.FromBoolean(mono));
197 scriptArr.Add(script);
200 body.Add(
"Script", scriptArr);
202 return BuildEvent(
"ScriptRunningReply", body);
206 ulong regionHandle,
int regionSizeX,
int regionSizeY)
210 {
"agent-id",
new OSDUUID(agentID)},
211 {
"sim-ip-and-port",
new OSDString(simIpAndPort)},
212 {
"seed-capability",
new OSDString(seedcap)},
213 {
"region-handle", OSD.FromULong(regionHandle)},
214 {
"region-size-x", OSD.FromUInteger((uint)regionSizeX)},
215 {
"region-size-y", OSD.FromUInteger((uint)regionSizeY)}
218 return BuildEvent(
"EstablishAgentCommunication", body);
223 return BuildEvent(
"FAKEEVENT",
new OSDMap());
226 public static OSD AgentParams(UUID agentID,
bool checkEstate,
int godLevel,
bool limitedToEstate)
230 body.Add(
"agent_id",
new OSDUUID(agentID));
231 body.Add(
"check_estate",
new OSDInteger(checkEstate ? 1 : 0));
232 body.Add(
"god_level",
new OSDInteger(godLevel));
233 body.Add(
"limited_to_estate",
new OSDInteger(limitedToEstate ? 1 : 0));
239 string fromName, byte dialog, uint timeStamp,
bool offline,
int parentEstateID,
240 Vector3 position, uint ttl, UUID transactionID,
bool fromGroup, byte[] binaryBucket)
243 messageParams.Add(
"type",
new OSDInteger((
int)dialog));
246 positionArray.Add(OSD.FromReal(position.X));
247 positionArray.Add(OSD.FromReal(position.Y));
248 positionArray.Add(OSD.FromReal(position.Z));
249 messageParams.Add(
"position", positionArray);
251 messageParams.Add(
"region_id",
new OSDUUID(UUID.Zero));
252 messageParams.Add(
"to_id",
new OSDUUID(toAgent));
253 messageParams.Add(
"source",
new OSDInteger(0));
256 data.Add(
"binary_bucket", OSD.FromBinary(binaryBucket));
257 messageParams.Add(
"data", data);
258 messageParams.Add(
"message",
new OSDString(message));
259 messageParams.Add(
"id",
new OSDUUID(transactionID));
260 messageParams.Add(
"from_name",
new OSDString(fromName));
261 messageParams.Add(
"timestamp",
new OSDInteger((
int)timeStamp));
262 messageParams.Add(
"offline",
new OSDInteger(offline ? 1 : 0));
263 messageParams.Add(
"parent_estate_id",
new OSDInteger(parentEstateID));
264 messageParams.Add(
"ttl",
new OSDInteger((
int)ttl));
265 messageParams.Add(
"from_id",
new OSDUUID(fromAgent));
266 messageParams.Add(
"from_group",
new OSDInteger(fromGroup ? 1 : 0));
268 return messageParams;
272 string fromName, byte dialog, uint timeStamp,
bool offline,
int parentEstateID,
273 Vector3 position, uint ttl, UUID transactionID,
bool fromGroup, byte[] binaryBucket,
274 bool checkEstate,
int godLevel,
bool limitedToEstate)
277 im.Add(
"message_params", InstantMessageParams(fromAgent, message, toAgent,
278 fromName, dialog, timeStamp, offline, parentEstateID,
279 position, ttl, transactionID, fromGroup, binaryBucket));
281 im.Add(
"agent_params", AgentParams(fromAgent, checkEstate, godLevel, limitedToEstate));
288 UUID fromAgent,
string message, UUID toAgent,
string fromName, byte dialog,
289 uint timeStamp,
bool offline,
int parentEstateID, Vector3 position,
290 uint ttl, UUID transactionID,
bool fromGroup, byte[] binaryBucket)
293 body.Add(
"session_id",
new OSDUUID(sessionID));
294 body.Add(
"from_name",
new OSDString(fromName));
295 body.Add(
"session_name",
new OSDString(sessionName));
296 body.Add(
"from_id",
new OSDUUID(fromAgent));
298 body.Add(
"instantmessage", InstantMessage(fromAgent, message, toAgent,
299 fromName, dialog, timeStamp, offline, parentEstateID, position,
300 ttl, transactionID, fromGroup, binaryBucket,
true, 0,
true));
303 chatterboxInvitation.Add(
"message",
new OSDString(
"ChatterBoxInvitation"));
304 chatterboxInvitation.Add(
"body", body);
305 return chatterboxInvitation;
309 UUID agentID,
bool canVoiceChat,
bool isModerator,
bool textMute)
316 mutes.Add(
"text", OSD.FromBoolean(textMute));
317 infoDetail.Add(
"can_voice_chat", OSD.FromBoolean(canVoiceChat));
318 infoDetail.Add(
"is_moderator", OSD.FromBoolean(isModerator));
319 infoDetail.Add(
"mutes", mutes);
321 info.Add(
"info", infoDetail);
322 agentUpdates.Add(agentID.ToString(), info);
323 body.Add(
"agent_updates", agentUpdates);
324 body.Add(
"session_id", OSD.FromUUID(sessionID));
325 body.Add(
"updates",
new OSD());
327 OSDMap chatterBoxSessionAgentListUpdates =
new OSDMap();
328 chatterBoxSessionAgentListUpdates.Add(
"message", OSD.FromString(
"ChatterBoxSessionAgentListUpdates"));
329 chatterBoxSessionAgentListUpdates.Add(
"body", body);
331 return chatterBoxSessionAgentListUpdates;
337 groupUpdate.Add(
"message", OSD.FromString(
"AgentGroupDataUpdate"));
342 agentDataMap.Add(
"AgentID", OSD.FromUUID(groupUpdatePacket.AgentData.AgentID));
343 agentData.Add(agentDataMap);
344 body.Add(
"AgentData", agentData);
348 foreach (AgentGroupDataUpdatePacket.GroupDataBlock groupDataBlock in groupUpdatePacket.GroupData)
351 groupDataMap.Add(
"ListInProfile", OSD.FromBoolean(
false));
352 groupDataMap.Add(
"GroupID", OSD.FromUUID(groupDataBlock.GroupID));
353 groupDataMap.Add(
"GroupInsigniaID", OSD.FromUUID(groupDataBlock.GroupInsigniaID));
354 groupDataMap.Add(
"Contribution", OSD.FromInteger(groupDataBlock.Contribution));
355 groupDataMap.Add(
"GroupPowers", OSD.FromBinary(ulongToByteArray(groupDataBlock.GroupPowers)));
356 groupDataMap.Add(
"GroupName", OSD.FromString(Utils.BytesToString(groupDataBlock.GroupName)));
357 groupDataMap.Add(
"AcceptNotices", OSD.FromBoolean(groupDataBlock.AcceptNotices));
359 groupData.Add(groupDataMap);
362 body.Add(
"GroupData", groupData);
363 groupUpdate.Add(
"body", body);
371 placesReply.Add(
"message", OSD.FromString(
"PlacesReplyMessage"));
376 agentDataMap.Add(
"AgentID", OSD.FromUUID(PlacesReply.AgentData.AgentID));
377 agentDataMap.Add(
"QueryID", OSD.FromUUID(PlacesReply.AgentData.QueryID));
378 agentDataMap.Add(
"TransactionID", OSD.FromUUID(PlacesReply.TransactionData.TransactionID));
379 agentData.Add(agentDataMap);
380 body.Add(
"AgentData", agentData);
384 foreach (PlacesReplyPacket.QueryDataBlock groupDataBlock in PlacesReply.QueryData)
387 QueryDataMap.Add(
"ActualArea", OSD.FromInteger(groupDataBlock.ActualArea));
388 QueryDataMap.Add(
"BillableArea", OSD.FromInteger(groupDataBlock.BillableArea));
389 QueryDataMap.Add(
"Description", OSD.FromBinary(groupDataBlock.Desc));
390 QueryDataMap.Add(
"Dwell", OSD.FromInteger((int)groupDataBlock.Dwell));
391 QueryDataMap.Add(
"Flags", OSD.FromString(Convert.ToString(groupDataBlock.Flags)));
392 QueryDataMap.Add(
"GlobalX", OSD.FromInteger((int)groupDataBlock.GlobalX));
393 QueryDataMap.Add(
"GlobalY", OSD.FromInteger((int)groupDataBlock.GlobalY));
394 QueryDataMap.Add(
"GlobalZ", OSD.FromInteger((int)groupDataBlock.GlobalZ));
395 QueryDataMap.Add(
"Name", OSD.FromBinary(groupDataBlock.Name));
396 QueryDataMap.Add(
"OwnerID", OSD.FromUUID(groupDataBlock.OwnerID));
397 QueryDataMap.Add(
"SimName", OSD.FromBinary(groupDataBlock.SimName));
398 QueryDataMap.Add(
"SnapShotID", OSD.FromUUID(groupDataBlock.SnapshotID));
399 QueryDataMap.Add(
"ProductSku", OSD.FromInteger(0));
400 QueryDataMap.Add(
"Price", OSD.FromInteger(groupDataBlock.Price));
402 QueryData.Add(QueryDataMap);
404 body.Add(
"QueryData", QueryData);
405 placesReply.Add(
"QueryData[]", body);
413 message.Add(
"message", OSD.FromString(
"ParcelProperties"));
414 OSD message_body = parcelPropertiesMessage.Serialize();
415 message.Add(
"body", message_body);
420 float density,
float friction,
float bounce,
float gravmod)
424 physinfo[
"LocalID"] = localID;
425 physinfo[
"Density"] = density;
426 physinfo[
"Friction"] = friction;
427 physinfo[
"GravityMultiplier"] = gravmod;
428 physinfo[
"Restitution"] = bounce;
429 physinfo[
"PhysicsShapeType"] = (int)physhapetype;
435 llsdBody.Add(
"ObjectData", array);
437 return BuildEvent(
"ObjectPhysicsProperties", llsdBody);
static OSD GroupMembership(AgentGroupDataUpdatePacket groupUpdatePacket)
static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap, ulong regionHandle, int regionSizeX, int regionSizeY)
OpenMetaverse.StructuredData.OSDArray OSDArray
OpenSim.Framework.Constants.TeleportFlags TeleportFlags
static OSD ChatterboxInvitation(UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket)
static OSD DisableSimulator(ulong handle)
static OSD PlacesQuery(PlacesReplyPacket PlacesReply)
OpenMetaverse.StructuredData.OSDMap OSDMap
static OSD ScriptRunningReplyEvent(UUID objectID, UUID itemID, bool running, bool mono)
static OSD ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID agentID, bool canVoiceChat, bool isModerator, bool textMute)
static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL, UUID agentID, UUID sessionID, int regionSizeX, int regionSizeY)
OpenMetaverse.StructuredData.OSD OSD
static OSD InstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket, bool checkEstate, int godLevel, bool limitedToEstate)
static OSD partPhysicsProperties(uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod)
static OSD ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage)
static OSD EnableSimulator(ulong handle, IPEndPoint endPoint, int regionSizeX, int regionSizeY)
static OSD BuildEvent(string eventName, OSD eventBody)
static OSD AgentParams(UUID agentID, bool checkEstate, int godLevel, bool limitedToEstate)
static OSD InstantMessageParams(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket)
static OSD TeleportFinishEvent(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY)
static OSD KeepAliveEvent()