Annotation of /trunk/ModularRex/RexNetwork/RexClientView.cs
Parent Directory
|
Revision Log
Revision 5 - (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 : | afrisby | 5 | using OpenSim.Region.ClientStack; |
| 12 : | afrisby | 2 | using OpenSim.Region.ClientStack.LindenUDP; |
| 13 : | |||
| 14 : | namespace ModularRex.RexNetwork | ||
| 15 : | { | ||
| 16 : | public delegate void RexAppearanceDelegate(RexClientView sender); | ||
| 17 : | |||
| 18 : | public delegate void RexFaceExpressionDelegate(RexClientView sender, List<string> vParams); | ||
| 19 : | |||
| 20 : | afrisby | 5 | public delegate void RexAvatarProperties(RexClientView sender, List<string> parameters); |
| 21 : | |||
| 22 : | afrisby | 3 | public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance |
| 23 : | afrisby | 2 | { |
| 24 : | afrisby | 4 | private static readonly ILog m_log = |
| 25 : | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 26 : | |||
| 27 : | private string m_rexAvatarURL; | ||
| 28 : | private string m_rexAuthURL; | ||
| 29 : | private string m_rexSkypeURL; | ||
| 30 : | |||
| 31 : | afrisby | 2 | public event RexAppearanceDelegate OnRexAppearance; |
| 32 : | public event RexFaceExpressionDelegate OnRexFaceExpression; | ||
| 33 : | afrisby | 5 | public event RexAvatarProperties OnRexAvatarProperties; |
| 34 : | afrisby | 2 | |
| 35 : | public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, | ||
| 36 : | LLPacketServer packServer, AgentCircuitManager authenSessions, UUID agentId, | ||
| 37 : | afrisby | 5 | UUID sessionId, uint circuitCode, EndPoint proxyEP, ClientStackUserSettings userSettings) |
| 38 : | afrisby | 2 | : base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 39 : | afrisby | 5 | sessionId, circuitCode, proxyEP, userSettings) |
| 40 : | afrisby | 2 | { |
| 41 : | OnGenericMessage += RealXtendClientView_OnGenericMessage; | ||
| 42 : | } | ||
| 43 : | |||
| 44 : | afrisby | 4 | public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, |
| 45 : | LLPacketServer packServer, AgentCircuitManager authenSessions, UUID agentId, | ||
| 46 : | afrisby | 5 | UUID sessionId, uint circuitCode, EndPoint proxyEP, string rexAvatarURL, string rexAuthURL, ClientStackUserSettings userSettings) |
| 47 : | afrisby | 4 | : base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 48 : | afrisby | 5 | sessionId, circuitCode, proxyEP, userSettings) |
| 49 : | afrisby | 4 | { |
| 50 : | OnGenericMessage += RealXtendClientView_OnGenericMessage; | ||
| 51 : | |||
| 52 : | RexAvatarURL = rexAvatarURL; | ||
| 53 : | RexAuthURL = rexAuthURL; | ||
| 54 : | } | ||
| 55 : | |||
| 56 : | public string RexAvatarURL | ||
| 57 : | { | ||
| 58 : | get { return m_rexAvatarURL; } | ||
| 59 : | set | ||
| 60 : | { | ||
| 61 : | m_rexAvatarURL = value; | ||
| 62 : | if (OnRexAppearance != null) | ||
| 63 : | { | ||
| 64 : | OnRexAppearance(this); | ||
| 65 : | return; | ||
| 66 : | } | ||
| 67 : | } | ||
| 68 : | } | ||
| 69 : | |||
| 70 : | public string RexSkypeURL | ||
| 71 : | { | ||
| 72 : | get { return m_rexSkypeURL; } | ||
| 73 : | set { m_rexSkypeURL = value; } | ||
| 74 : | } | ||
| 75 : | |||
| 76 : | public string RexAuthURL | ||
| 77 : | { | ||
| 78 : | get { return m_rexAuthURL; } | ||
| 79 : | set | ||
| 80 : | { | ||
| 81 : | m_rexAuthURL = value; | ||
| 82 : | |||
| 83 : | // Request Agent Properties Asynchronously | ||
| 84 : | ThreadPool.QueueUserWorkItem(RequestProperties); | ||
| 85 : | } | ||
| 86 : | } | ||
| 87 : | |||
| 88 : | afrisby | 2 | void RealXtendClientView_OnGenericMessage(object sender, string method, List<string> args) |
| 89 : | { | ||
| 90 : | //TODO: Convert to Dictionary<Method, GenericMessageHandler> | ||
| 91 : | |||
| 92 : | if (method == "RexAppearance") | ||
| 93 : | if (OnRexAppearance != null) | ||
| 94 : | { | ||
| 95 : | OnRexAppearance(this); | ||
| 96 : | return; | ||
| 97 : | } | ||
| 98 : | |||
| 99 : | afrisby | 4 | if (method == "RexFaceExpression") |
| 100 : | afrisby | 2 | { |
| 101 : | afrisby | 4 | if (OnRexFaceExpression != null) |
| 102 : | afrisby | 2 | { |
| 103 : | OnRexFaceExpression(this, args); | ||
| 104 : | afrisby | 5 | return; |
| 105 : | afrisby | 2 | } |
| 106 : | } | ||
| 107 : | afrisby | 5 | |
| 108 : | if (method == "RexAvatarProp") | ||
| 109 : | { | ||
| 110 : | if(OnRexAvatarProperties != null) | ||
| 111 : | { | ||
| 112 : | OnRexAvatarProperties(this, args); | ||
| 113 : | return; | ||
| 114 : | } | ||
| 115 : | } | ||
| 116 : | |||
| 117 : | m_log.Warn("[REXCLIENTVIEW] Unhandled GenericMessage (" + method + ") {"); | ||
| 118 : | foreach (string s in args) | ||
| 119 : | { | ||
| 120 : | m_log.Warn("\t" + s); | ||
| 121 : | } | ||
| 122 : | m_log.Warn("}"); | ||
| 123 : | |||
| 124 : | afrisby | 2 | } |
| 125 : | |||
| 126 : | afrisby | 5 | public void SendRexScriptCommand(string unit, string command, string parameters) |
| 127 : | { | ||
| 128 : | List<string> pack = new List<string>(); | ||
| 129 : | |||
| 130 : | pack.Add(unit); | ||
| 131 : | pack.Add(command); | ||
| 132 : | |||
| 133 : | if (!string.IsNullOrEmpty(parameters)) | ||
| 134 : | pack.Add(parameters); | ||
| 135 : | |||
| 136 : | SendGenericMessage("RexScr", pack); | ||
| 137 : | } | ||
| 138 : | |||
| 139 : | public void SendRexInventoryMessage(string message) | ||
| 140 : | { | ||
| 141 : | SendRexScriptCommand("hud", "ShowInventoryMessage(\"" + message + "\")", ""); | ||
| 142 : | } | ||
| 143 : | |||
| 144 : | afrisby | 2 | public void SendRexFaceExpression(List<string> expressionData) |
| 145 : | { | ||
| 146 : | expressionData.Insert(0, AgentId.ToString()); | ||
| 147 : | SendGenericMessage("RexFaceExpression", expressionData); | ||
| 148 : | } | ||
| 149 : | |||
| 150 : | public void SendRexAppearance(UUID agentID, string avatarURL) | ||
| 151 : | { | ||
| 152 : | List<string> pack = new List<string>(); | ||
| 153 : | pack.Add(avatarURL); | ||
| 154 : | pack.Add(agentID.ToString()); | ||
| 155 : | |||
| 156 : | SendGenericMessage("RexAppearance", pack); | ||
| 157 : | } | ||
| 158 : | afrisby | 4 | |
| 159 : | /// <summary> | ||
| 160 : | /// Requests properties about this agent from their | ||
| 161 : | /// authentication server. This should be run in | ||
| 162 : | /// an async thread. | ||
| 163 : | /// | ||
| 164 : | /// Note that this particular function may set the | ||
| 165 : | /// avatars appearance which may in turn call | ||
| 166 : | /// additional modules and functions elsewhere. | ||
| 167 : | /// </summary> | ||
| 168 : | /// <param name="o"></param> | ||
| 169 : | private void RequestProperties(object o) | ||
| 170 : | { | ||
| 171 : | m_log.Info("[REXCLIENT] Resolving avatar..."); | ||
| 172 : | Hashtable ReqVals = new Hashtable(); | ||
| 173 : | ReqVals["avatar_uuid"] = AgentId.ToString(); | ||
| 174 : | ReqVals["AuthenticationAddress"] = RexAuthURL; | ||
| 175 : | |||
| 176 : | ArrayList SendParams = new ArrayList(); | ||
| 177 : | SendParams.Add(ReqVals); | ||
| 178 : | |||
| 179 : | XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", SendParams); | ||
| 180 : | |||
| 181 : | m_log.Info("[REXCLIENT] Sending XMLRPC Request to " + RexAuthURL); | ||
| 182 : | XmlRpcResponse authreply = req.Send(RexAuthURL, 9000); | ||
| 183 : | string rexAsAddress = ((Hashtable)authreply.Value)["as_address"].ToString(); | ||
| 184 : | string rexSkypeURL = ((Hashtable)authreply.Value)["skype_url"].ToString(); | ||
| 185 : | UUID userID = new UUID(((Hashtable) authreply.Value)["uuid"].ToString()); | ||
| 186 : | |||
| 187 : | // Sanity check | ||
| 188 : | if (userID == AgentId) | ||
| 189 : | { | ||
| 190 : | RexAvatarURL = rexAsAddress; | ||
| 191 : | RexSkypeURL = rexSkypeURL; | ||
| 192 : | } | ||
| 193 : | } | ||
| 194 : | afrisby | 2 | } |
| 195 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

