| 1 |
using System.Collections.Generic; |
using System.Collections; |
| 2 |
|
using System.Collections.Generic; |
| 3 |
using System.Net; |
using System.Net; |
| 4 |
|
using System.Reflection; |
| 5 |
|
using System.Threading; |
| 6 |
|
using log4net; |
| 7 |
|
using Nwc.XmlRpc; |
| 8 |
using OpenMetaverse; |
using OpenMetaverse; |
| 9 |
using OpenSim.Framework; |
using OpenSim.Framework; |
| 10 |
using OpenSim.Framework.Communications.Cache; |
using OpenSim.Framework.Communications.Cache; |
| 18 |
|
|
| 19 |
public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance |
public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance |
| 20 |
{ |
{ |
| 21 |
|
private static readonly ILog m_log = |
| 22 |
|
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
| 23 |
|
|
| 24 |
|
private string m_rexAvatarURL; |
| 25 |
|
private string m_rexAuthURL; |
| 26 |
|
private string m_rexSkypeURL; |
| 27 |
|
|
| 28 |
public event RexAppearanceDelegate OnRexAppearance; |
public event RexAppearanceDelegate OnRexAppearance; |
| 29 |
public event RexFaceExpressionDelegate OnRexFaceExpression; |
public event RexFaceExpressionDelegate OnRexFaceExpression; |
| 30 |
|
|
| 37 |
OnGenericMessage += RealXtendClientView_OnGenericMessage; |
OnGenericMessage += RealXtendClientView_OnGenericMessage; |
| 38 |
} |
} |
| 39 |
|
|
| 40 |
|
public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, |
| 41 |
|
LLPacketServer packServer, AgentCircuitManager authenSessions, UUID agentId, |
| 42 |
|
UUID sessionId, uint circuitCode, EndPoint proxyEP, string rexAvatarURL, string rexAuthURL) |
| 43 |
|
: base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 44 |
|
sessionId, circuitCode, proxyEP) |
| 45 |
|
{ |
| 46 |
|
OnGenericMessage += RealXtendClientView_OnGenericMessage; |
| 47 |
|
|
| 48 |
|
RexAvatarURL = rexAvatarURL; |
| 49 |
|
RexAuthURL = rexAuthURL; |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
public string RexAvatarURL |
| 53 |
|
{ |
| 54 |
|
get { return m_rexAvatarURL; } |
| 55 |
|
set |
| 56 |
|
{ |
| 57 |
|
m_rexAvatarURL = value; |
| 58 |
|
if (OnRexAppearance != null) |
| 59 |
|
{ |
| 60 |
|
OnRexAppearance(this); |
| 61 |
|
return; |
| 62 |
|
} |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
public string RexSkypeURL |
| 67 |
|
{ |
| 68 |
|
get { return m_rexSkypeURL; } |
| 69 |
|
set { m_rexSkypeURL = value; } |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
public string RexAuthURL |
| 73 |
|
{ |
| 74 |
|
get { return m_rexAuthURL; } |
| 75 |
|
set |
| 76 |
|
{ |
| 77 |
|
m_rexAuthURL = value; |
| 78 |
|
|
| 79 |
|
// Request Agent Properties Asynchronously |
| 80 |
|
ThreadPool.QueueUserWorkItem(RequestProperties); |
| 81 |
|
} |
| 82 |
|
} |
| 83 |
|
|
| 84 |
void RealXtendClientView_OnGenericMessage(object sender, string method, List<string> args) |
void RealXtendClientView_OnGenericMessage(object sender, string method, List<string> args) |
| 85 |
{ |
{ |
| 86 |
//TODO: Convert to Dictionary<Method, GenericMessageHandler> |
//TODO: Convert to Dictionary<Method, GenericMessageHandler> |
| 115 |
|
|
| 116 |
SendGenericMessage("RexAppearance", pack); |
SendGenericMessage("RexAppearance", pack); |
| 117 |
} |
} |
| 118 |
|
|
| 119 |
|
/// <summary> |
| 120 |
|
/// Requests properties about this agent from their |
| 121 |
|
/// authentication server. This should be run in |
| 122 |
|
/// an async thread. |
| 123 |
|
/// |
| 124 |
|
/// Note that this particular function may set the |
| 125 |
|
/// avatars appearance which may in turn call |
| 126 |
|
/// additional modules and functions elsewhere. |
| 127 |
|
/// </summary> |
| 128 |
|
/// <param name="o"></param> |
| 129 |
|
private void RequestProperties(object o) |
| 130 |
|
{ |
| 131 |
|
m_log.Info("[REXCLIENT] Resolving avatar..."); |
| 132 |
|
Hashtable ReqVals = new Hashtable(); |
| 133 |
|
ReqVals["avatar_uuid"] = AgentId.ToString(); |
| 134 |
|
ReqVals["AuthenticationAddress"] = RexAuthURL; |
| 135 |
|
|
| 136 |
|
ArrayList SendParams = new ArrayList(); |
| 137 |
|
SendParams.Add(ReqVals); |
| 138 |
|
|
| 139 |
|
XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", SendParams); |
| 140 |
|
|
| 141 |
|
m_log.Info("[REXCLIENT] Sending XMLRPC Request to " + RexAuthURL); |
| 142 |
|
XmlRpcResponse authreply = req.Send(RexAuthURL, 9000); |
| 143 |
|
string rexAsAddress = ((Hashtable)authreply.Value)["as_address"].ToString(); |
| 144 |
|
string rexSkypeURL = ((Hashtable)authreply.Value)["skype_url"].ToString(); |
| 145 |
|
UUID userID = new UUID(((Hashtable) authreply.Value)["uuid"].ToString()); |
| 146 |
|
|
| 147 |
|
// Sanity check |
| 148 |
|
if (userID == AgentId) |
| 149 |
|
{ |
| 150 |
|
RexAvatarURL = rexAsAddress; |
| 151 |
|
RexSkypeURL = rexSkypeURL; |
| 152 |
|
} |
| 153 |
|
} |
| 154 |
} |
} |
| 155 |
} |
} |