public StatusNotification ( List |
||
friends | List |
|
userID | UUID | |
online | bool | |
Résultat | List |
public List<UUID> StatusNotification(List<string> friends, UUID userID, bool online)
{
Hashtable hash = new Hashtable ();
hash["userID"] = userID.ToString ();
hash["online"] = online.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 ("status_notification", paramList);
string reason = string.Empty;
// Send and get reply
List<UUID> friendsOnline = new List<UUID> ();
XmlRpcResponse response = null;
try
{
response = request.Send (m_ServerURL, 6000);
}
catch (Exception e)
{
MainConsole.Instance.DebugFormat ("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
reason = "Exception: " + e.Message;
return friendsOnline;
}
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 friendsOnline;
}
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 friendsOnline;
}
// 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))
friendsOnline.Add (uuid);
}
}
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat ("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
reason = "Exception: " + e.Message;
}
return friendsOnline;
}
public bool RemoteStatusNotification(FriendInfo friend, UUID userID, bool online) { string url, first, last, secret; UUID FriendToInform; if (HGUtil.ParseUniversalUserIdentifier(friend.Friend, out FriendToInform, out url, out first, out last, out secret)) { UserAgentServiceConnector connector = new UserAgentServiceConnector(url); List <UUID> informedFriends = connector.StatusNotification(new List <string> (new string[1] { FriendToInform.ToString() }), userID, online); return(informedFriends.Count > 0); } return(false); }