Annotation of /trunk/ModularRex/RexNetwork/RexClientView.cs
Parent Directory
|
Revision Log
Revision 4 - (view) (download)
| 1 : | afrisby | 4 | using System.Collections; |
| 2 : | using System.Collections.Generic; | ||
| 3 : | afrisby | 2 | using System.Net; |
| 4 : | afrisby | 4 | using System.Reflection; |
| 5 : | using System.Threading; | ||
| 6 : | using log4net; | ||
| 7 : | using Nwc.XmlRpc; | ||
| 8 : | afrisby | 2 | using OpenMetaverse; |
| 9 : | using OpenSim.Framework; | ||
| 10 : | using OpenSim.Framework.Communications.Cache; | ||
| 11 : | using OpenSim.Region.ClientStack.LindenUDP; | ||
| 12 : | |||
| 13 : | namespace ModularRex.RexNetwork | ||
| 14 : | { | ||
| 15 : | public delegate void RexAppearanceDelegate(RexClientView sender); | ||
| 16 : | |||
| 17 : | public delegate void RexFaceExpressionDelegate(RexClientView sender, List<string> vParams); | ||
| 18 : | |||
| 19 : | afrisby | 3 | public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance |
| 20 : | afrisby | 2 | { |
| 21 : | afrisby | 4 | 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 : | afrisby | 2 | public event RexAppearanceDelegate OnRexAppearance; |
| 29 : | public event RexFaceExpressionDelegate OnRexFaceExpression; | ||
| 30 : | |||
| 31 : | public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, | ||
| 32 : | LLPacketServer packServer, AgentCircuitManager authenSessions, UUID agentId, | ||
| 33 : | UUID sessionId, uint circuitCode, EndPoint proxyEP) | ||
| 34 : | : base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, | ||
| 35 : | sessionId, circuitCode, proxyEP) | ||
| 36 : | { | ||
| 37 : | OnGenericMessage += RealXtendClientView_OnGenericMessage; | ||
| 38 : | } | ||
| 39 : | |||
| 40 : | afrisby | 4 | 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 : | afrisby | 2 | void RealXtendClientView_OnGenericMessage(object sender, string method, List<string> args) |
| 85 : | { | ||
| 86 : | //TODO: Convert to Dictionary<Method, GenericMessageHandler> | ||
| 87 : | |||
| 88 : | if (method == "RexAppearance") | ||
| 89 : | if (OnRexAppearance != null) | ||
| 90 : | { | ||
| 91 : | OnRexAppearance(this); | ||
| 92 : | return; | ||
| 93 : | } | ||
| 94 : | |||
| 95 : | afrisby | 4 | if (method == "RexFaceExpression") |
| 96 : | afrisby | 2 | { |
| 97 : | afrisby | 4 | if (OnRexFaceExpression != null) |
| 98 : | afrisby | 2 | { |
| 99 : | OnRexFaceExpression(this, args); | ||
| 100 : | } | ||
| 101 : | } | ||
| 102 : | } | ||
| 103 : | |||
| 104 : | public void SendRexFaceExpression(List<string> expressionData) | ||
| 105 : | { | ||
| 106 : | expressionData.Insert(0, AgentId.ToString()); | ||
| 107 : | SendGenericMessage("RexFaceExpression", expressionData); | ||
| 108 : | } | ||
| 109 : | |||
| 110 : | public void SendRexAppearance(UUID agentID, string avatarURL) | ||
| 111 : | { | ||
| 112 : | List<string> pack = new List<string>(); | ||
| 113 : | pack.Add(avatarURL); | ||
| 114 : | pack.Add(agentID.ToString()); | ||
| 115 : | |||
| 116 : | SendGenericMessage("RexAppearance", pack); | ||
| 117 : | } | ||
| 118 : | afrisby | 4 | |
| 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 : | afrisby | 2 | } |
| 155 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

