public List<UUID> GetOnlineFriends(UUID userID, List<string> friends)
{
Hashtable hash = new Hashtable ();
hash["userID"] = userID.ToString ();
int i = 0;
foreach (string s in friends)
{
hash["friend_" + i.ToString ()] = s;
i++;
}
IList paramList = new ArrayList ();
paramList.Add (hash);
XmlRpcRequest request = new XmlRpcRequest ("get_online_friends", paramList);
string reason = string.Empty;
// Send and get reply
List<UUID> online = new List<UUID> ();
XmlRpcResponse response = null;
try
{
response = request.Send (m_ServerURL, 10000);
}
catch (Exception e)
{
MainConsole.Instance.DebugFormat ("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
reason = "Exception: " + e.Message;
return online;
}
if (response.IsFault)
{
MainConsole.Instance.ErrorFormat ("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
reason = "XMLRPC Fault";
return online;
}
hash = (Hashtable)response.Value;
//foreach (Object o in hash)
// MainConsole.Instance.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
try
{
if (hash == null)
{
MainConsole.Instance.ErrorFormat ("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
reason = "Internal error 1";
return online;
}
// Here is the actual response
foreach (object key in hash.Keys)
{
if (key is string && ((string)key).StartsWith ("friend_") && hash[key] != null)
{
UUID uuid;
if (UUID.TryParse (hash[key].ToString (), out uuid))
online.Add (uuid);
}
}
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat ("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
reason = "Exception: " + e.Message;
}
return online;
}