Added IGridDialogModule and GridDialogModule to support dialog in DSG mode.

dsg
Huaiyu (Kitty) Liu 2011-05-27 10:54:31 -07:00
parent 67eaa574a3
commit 40809775dd
3 changed files with 4 additions and 166 deletions

View File

@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
HandleAlertConsoleCommand);
}
//public void PostInitialise() {}
public void PostInitialise() {}
public void Close() {}
public string Name { get { return "Dialog Module"; } }
public bool IsSharedModule { get { return false; } }
@ -221,161 +221,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
return result;
}
#region GridCommunication
private IPresenceService m_PresenceService;
protected IPresenceService PresenceService
{
get
{
if (m_PresenceService == null)
m_PresenceService = m_scene.RequestModuleInterface<IPresenceService>();
return m_PresenceService;
}
}
//DSG added to support llDialog with distributed script engine and client manager,
//following the same communication pattern as grid_instant_message
public virtual void SendGridDialogViaXMLRPCAsync(UUID avatarID, string objectName, UUID objectID, string ownerFirstName,
string ownerLastName, string message, UUID textureID, int ch, string[] buttonlabels, UUID prevRegionID)
{
UUID toAgentID;
PresenceInfo upd = null;
// Non-cached user agent lookup.
PresenceInfo[] presences = PresenceService.GetAgents(new string[] { avatarID.ToString() });
if (presences != null && presences.Length > 0)
{
foreach (PresenceInfo p in presences)
{
if (p.RegionID != UUID.Zero)
{
upd = p;
break;
}
}
if (upd != null)
{
// check if we've tried this before..
// This is one way to end the recursive loop
//
if (upd.RegionID == prevRegionID)
{
//Dialog content undelivered
m_log.WarnFormat("Couldn't deliver dialog to {0}" + avatarID);
return;
}
}
else
{
//Dialog content undelivered
m_log.WarnFormat("Couldn't deliver dialog to {0}" + toAgentID);
return;
}
}
if (upd != null)
{
GridRegion reginfo = m_scene.GridService.GetRegionByUUID(m_scene.RegionInfo.ScopeID,
upd.RegionID);
if (reginfo != null)
{
Hashtable msgdata = ConvertGridDialogToXMLRPC(avatarID, objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels);
//= ConvertGridInstantMessageToXMLRPC(im);
// Not actually used anymore, left in for compatibility
// Remove at next interface change
//
msgdata["region_handle"] = 0;
bool imresult = doDialogSending(reginfo, msgdata);
if (imresult)
{
SendGridDialogViaXMLRPCAsync(avatarID, objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels, prevRegionID);
}
}
}
}
private Hashtable ConvertGridDialogToXMLRPC(UUID avatarID, string objectName, UUID objectID, string ownerFirstName, string ownerLastName,
string message, UUID textureID, int ch, string[] buttonlabels)
{
Hashtable msgdata = new Hashtable();
return msgdata;
}
/// <summary>
/// This actually does the XMLRPC Request
/// </summary>
/// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param>
/// <param name="xmlrpcdata">The Instant Message data Hashtable</param>
/// <returns>Bool if the message was successfully delivered at the other side.</returns>
protected virtual bool doDialogSending(GridRegion reginfo, Hashtable xmlrpcdata)
{
ArrayList SendParams = new ArrayList();
SendParams.Add(xmlrpcdata);
XmlRpcRequest GridReq = new XmlRpcRequest("grid_dialog", SendParams);
try
{
XmlRpcResponse GridResp = GridReq.Send(reginfo.ServerURI, 3000);
Hashtable responseData = (Hashtable)GridResp.Value;
if (responseData.ContainsKey("success"))
{
if ((string)responseData["success"] == "TRUE")
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
catch (WebException e)
{
m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending grid_dialog to {0} the host didn't respond " + e.ToString(), reginfo.ServerURI.ToString());
}
return false;
}
public virtual void PostInitialise()
{
MainServer.Instance.AddXmlRPCHandler(
"grid_dialog", processXMLRPCGridDialog);
}
/// <summary>
/// Process a XMLRPC Grid Instant Message
/// </summary>
/// <param name="request">XMLRPC parameters
/// </param>
/// <returns>Nothing much</returns>
protected virtual XmlRpcResponse processXMLRPCGridDialog(XmlRpcRequest request, IPEndPoint remoteClient)
{
bool successful = false;
//Send response back to region calling if it was successful
// calling region uses this to know when to look up a user's location again.
XmlRpcResponse resp = new XmlRpcResponse();
Hashtable respdata = new Hashtable();
if (successful)
respdata["success"] = "TRUE";
else
respdata["success"] = "FALSE";
resp.Value = respdata;
return resp;
}
#endregion //GridCommunication
}
}

View File

@ -617,13 +617,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
public virtual void SendDialog(string objectname, UUID objectID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels)
{
IDialogModule dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
IGridDialogModule gridDialogModule = m_scene.RequestModuleInterface<IGridDialogModule>();
if (dialogModule != null)
if (gridDialogModule != null)
{
//Seems that the two places calling DialogModule.SendDialogToUser, which calls current function, is
//pass (new UUID("00000000-0000-2222-3333-100000001000")) as the ownerID, so we copy that.
dialogModule.SendGridDialogViaXMLRPCAsync(this.AgentId, objectname, objectID, ownerFirstName, ownerLastName,
gridDialogModule.SendGridDialogViaXMLRPCAsync(this.AgentId, objectname, objectID, ownerFirstName, ownerLastName,
msg, textureID, ch, buttonlabels, UUID.Zero);
}
}

View File

@ -123,9 +123,5 @@ namespace OpenSim.Region.Framework.Interfaces
/// Send a textbox entry for the client to respond to
/// </summary>
void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid);
//DSG added
void SendGridDialogViaXMLRPCAsync(UUID avatarID, string objectName, UUID objectID, string ownerFirstName, string ownerLastName,
string message, UUID textureID, int ch, string[] buttonlabels, UUID prevRegionID);
}
}