add event queue code for sending group IM for future group support

0.6.3-post-fixes
Dahlia Trimble 2009-01-23 01:49:32 +00:00
parent 178fd97bd0
commit 68978e6e2a
3 changed files with 112 additions and 2 deletions

View File

@ -35,6 +35,7 @@ using System.Timers;
using System.Xml; using System.Xml;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
using OpenMetaverse.StructuredData;
using log4net; using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Client; using OpenSim.Framework.Client;
@ -1182,6 +1183,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
string fromName, byte dialog, uint timeStamp, string fromName, byte dialog, uint timeStamp,
UUID transactionID, bool fromGroup, byte[] binaryBucket) UUID transactionID, bool fromGroup, byte[] binaryBucket)
{ {
if (((Scene)(m_scene)).Permissions.CanInstantMessage(fromAgent, toAgent)) if (((Scene)(m_scene)).Permissions.CanInstantMessage(fromAgent, toAgent))
{ {
ImprovedInstantMessagePacket msg ImprovedInstantMessagePacket msg
@ -1205,7 +1207,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
msg.MessageBlock.Message = Utils.StringToBytes(message); msg.MessageBlock.Message = Utils.StringToBytes(message);
msg.MessageBlock.BinaryBucket = binaryBucket; msg.MessageBlock.BinaryBucket = binaryBucket;
//System.Console.WriteLine("SendInstantMessage: " + msg); if (message.StartsWith("[grouptest]"))
{ // this block is test code for implementing group IM - delete when group IM is finished
IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
if (eq != null)
{
dialog = 17;
//OSD Item = Environment.EventQueueHelper.ChatterboxInvitation(
// new UUID("00000000-68f9-1111-024e-222222111123"),
// "Test Group", fromAgent, message, toAgent, fromName, dialog, 0,
// false, 0, new Vector3(), 1, transactionID, fromGroup,
// Utils.StringToBytes("Test Group"));
OSD Item = Environment.EventQueueHelper.ChatterboxInvitation(
new UUID("00000000-68f9-1111-024e-222222111123"),
"Test Group", fromAgent, message, toAgent, fromName, dialog, 0,
false, 0, new Vector3(), 1, transactionID, fromGroup, binaryBucket);
eq.Enqueue(Item, toAgent);
m_log.Info("########### eq chatterbox invitation #############\n" + Item);
}
System.Console.WriteLine("SendInstantMessage: " + msg);
}
else
OutPacket(msg, ThrottleOutPacketType.Task); OutPacket(msg, ThrottleOutPacketType.Task);
} }
} }

View File

@ -28,6 +28,7 @@
using System; using System;
using System.Net; using System.Net;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
namespace OpenSim.Region.Environment namespace OpenSim.Region.Environment
@ -192,5 +193,87 @@ namespace OpenSim.Region.Environment
{ {
return buildEvent("FAKEEVENT", new OSDMap()); return buildEvent("FAKEEVENT", new OSDMap());
} }
public static OSD AgentParams(UUID agentID, bool checkEstate, int godLevel, bool limitedToEstate)
{
OSDMap body = new OSDMap(4);
body.Add("agent_id", new OSDUUID(agentID));
body.Add("check_estate", new OSDInteger(checkEstate ? 1 : 0));
body.Add("god_level", new OSDInteger(godLevel));
body.Add("limited_to_estate", new OSDInteger(limitedToEstate ? 1 : 0));
return body;
}
public 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)
{
OSDMap messageParams = new OSDMap(15);
messageParams.Add("type", new OSDInteger((int)dialog));
OSDArray positionArray = new OSDArray(3);
positionArray.Add(OSD.FromReal(position.X));
positionArray.Add(OSD.FromReal(position.Y));
positionArray.Add(OSD.FromReal(position.Z));
messageParams.Add("position", positionArray);
messageParams.Add("region_id", new OSDUUID(UUID.Zero));
messageParams.Add("to_id", new OSDUUID(toAgent));
messageParams.Add("source", new OSDInteger(0));
OSDMap data = new OSDMap(1);
data.Add("binary_bucket", OSD.FromBinary(binaryBucket));
messageParams.Add("data", data);
messageParams.Add("message", new OSDString(message));
messageParams.Add("id", new OSDUUID(transactionID));
messageParams.Add("from_name", new OSDString(fromName));
messageParams.Add("timestamp", new OSDInteger((int)timeStamp));
messageParams.Add("offline", new OSDInteger(offline ? 1 : 0));
messageParams.Add("parent_estate_id", new OSDInteger(parentEstateID));
messageParams.Add("ttl", new OSDInteger((int)ttl));
messageParams.Add("from_id", new OSDUUID(fromAgent));
messageParams.Add("from_group", new OSDInteger(fromGroup ? 1 : 0));
return messageParams;
}
public 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)
{
OSDMap im = new OSDMap(2);
im.Add("message_params", InstantMessageParams(fromAgent, message, toAgent,
fromName, dialog, timeStamp, offline, parentEstateID,
position, ttl, transactionID, fromGroup, binaryBucket));
im.Add("agent_params", AgentParams(fromAgent, checkEstate, godLevel, limitedToEstate));
return im;
}
public 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)
{
OSDMap body = new OSDMap(5);
body.Add("session_id", new OSDUUID(sessionID));
body.Add("from_name", new OSDString(fromName));
body.Add("session_name", new OSDString(sessionName));
body.Add("from_id", new OSDUUID(fromAgent));
body.Add("instantmessage", InstantMessage(fromAgent, message, toAgent,
fromName, dialog, timeStamp, offline, parentEstateID, position,
ttl, transactionID, fromGroup, binaryBucket, true, 0, true));
OSDMap chatterboxInvitation = new OSDMap(2);
chatterboxInvitation.Add("message", new OSDString("ChatterBoxInvitation"));
chatterboxInvitation.Add("body", body);
return chatterboxInvitation;
}
} }
} }

View File

@ -1059,6 +1059,7 @@
<Reference name="System" localCopy="false"/> <Reference name="System" localCopy="false"/>
<Reference name="System.Xml"/> <Reference name="System.Xml"/>
<Reference name="OpenMetaverseTypes.dll"/> <Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="OpenMetaverse.dll"/> <Reference name="OpenMetaverse.dll"/>
<Reference name="OpenSim.Region.Environment"/> <Reference name="OpenSim.Region.Environment"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>