private bool SendIM(GridInstantMessage gim)
{
string HTTPPath = "";
List<string> AgentLocations = m_registry.RequestModuleInterface<IAgentInfoService> ().GetAgentsLocations (gim.fromAgentID.ToString(), new List<string>() { gim.toAgentID.ToString () });
if (AgentLocations.Count > 0)
{
//No agents, so this user is offline
if (AgentLocations[0] == "NotOnline")
{
lock (IMUsersCache)
{
//Remove them so we keep testing against the db
IMUsersCache.Remove (gim.toAgentID);
}
return false;
}
else //Found the agent, use this location
HTTPPath = AgentLocations[0];
}
//We found the agent's location, now ask them about the user
if (HTTPPath != "")
{
Hashtable msgdata = ConvertGridInstantMessageToXMLRPC (gim);
if (!doIMSending (HTTPPath, msgdata))
{
//It failed, stop now
lock (IMUsersCache)
{
//Remove them so we keep testing against the db
IMUsersCache.Remove (gim.toAgentID);
}
MainConsole.Instance.Info ("[GRID INSTANT MESSAGE]: Unable to deliver an instant message as the region could not be found");
return false;
}
else
{
//Add to the cache
if (!IMUsersCache.ContainsKey (gim.toAgentID))
IMUsersCache.Add (gim.toAgentID, HTTPPath);
return true;
}
}
else
{
//Couldn't find them, stop for now
lock (IMUsersCache)
{
//Remove them so we keep testing against the db
IMUsersCache.Remove (gim.toAgentID);
}
return false;
}
}