Annotation of /trunk/ModularRex/RexNetwork/RexClientView.cs
Parent Directory
|
Revision Log
Revision 12 - (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 | 11 | /// <summary> |
| 23 : | /// Inherits from LLClientView the majority of functionality | ||
| 24 : | /// Overrides and extends for Rex-specific functionality. | ||
| 25 : | /// | ||
| 26 : | /// In the case whereby functionality uses the same packets but differs | ||
| 27 : | /// between Rex and LL, you can use a override on those specific functions | ||
| 28 : | /// to overload the request. | ||
| 29 : | /// </summary> | ||
| 30 : | afrisby | 3 | public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance |
| 31 : | afrisby | 2 | { |
| 32 : | afrisby | 4 | private static readonly ILog m_log = |
| 33 : | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 34 : | |||
| 35 : | afrisby | 10 | private string m_rexAccountID; |
| 36 : | afrisby | 4 | private string m_rexAvatarURL; |
| 37 : | private string m_rexAuthURL; | ||
| 38 : | private string m_rexSkypeURL; | ||
| 39 : | mikkopa | 12 | public string AvatarStorageOverride; |
| 40 : | public float RexMovementSpeedMod; | ||
| 41 : | public bool RexWalkDisabled; | ||
| 42 : | public bool RexFlyDisabled; | ||
| 43 : | afrisby | 4 | |
| 44 : | afrisby | 2 | public event RexAppearanceDelegate OnRexAppearance; |
| 45 : | public event RexFaceExpressionDelegate OnRexFaceExpression; | ||
| 46 : | afrisby | 5 | public event RexAvatarProperties OnRexAvatarProperties; |
| 47 : | afrisby | 2 | |
| 48 : | public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, | ||
| 49 : | afrisby | 6 | LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
| 50 : | afrisby | 5 | UUID sessionId, uint circuitCode, EndPoint proxyEP, ClientStackUserSettings userSettings) |
| 51 : | afrisby | 2 | : base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 52 : | afrisby | 5 | sessionId, circuitCode, proxyEP, userSettings) |
| 53 : | afrisby | 2 | { |
| 54 : | afrisby | 11 | // Rex communication now occurs via GenericMessage |
| 55 : | // We have a special handler here below. | ||
| 56 : | afrisby | 2 | OnGenericMessage += RealXtendClientView_OnGenericMessage; |
| 57 : | } | ||
| 58 : | |||
| 59 : | afrisby | 4 | public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, |
| 60 : | afrisby | 6 | LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
| 61 : | afrisby | 5 | UUID sessionId, uint circuitCode, EndPoint proxyEP, string rexAvatarURL, string rexAuthURL, ClientStackUserSettings userSettings) |
| 62 : | afrisby | 4 | : base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 63 : | afrisby | 5 | sessionId, circuitCode, proxyEP, userSettings) |
| 64 : | afrisby | 4 | { |
| 65 : | afrisby | 11 | // Rex communication now occurs via GenericMessage |
| 66 : | // We have a special handler here below. | ||
| 67 : | afrisby | 4 | OnGenericMessage += RealXtendClientView_OnGenericMessage; |
| 68 : | |||
| 69 : | RexAvatarURL = rexAvatarURL; | ||
| 70 : | RexAuthURL = rexAuthURL; | ||
| 71 : | } | ||
| 72 : | |||
| 73 : | afrisby | 11 | /// <summary> |
| 74 : | /// Registers interfaces for IClientCore, | ||
| 75 : | /// every time you make a new Rex-specific | ||
| 76 : | /// Interface. Make sure to register it here. | ||
| 77 : | /// </summary> | ||
| 78 : | afrisby | 9 | protected override void RegisterInterfaces() |
| 79 : | { | ||
| 80 : | RegisterInterface<IClientRexAppearance>(this); | ||
| 81 : | RegisterInterface<IClientRexFaceExpression>(this); | ||
| 82 : | RegisterInterface<RexClientView>(this); | ||
| 83 : | |||
| 84 : | base.RegisterInterfaces(); | ||
| 85 : | } | ||
| 86 : | |||
| 87 : | afrisby | 11 | /// <summary> |
| 88 : | /// The avatar URL for this avatar | ||
| 89 : | /// Eg: http://avatar.com:10000/uuid/ | ||
| 90 : | /// </summary> | ||
| 91 : | afrisby | 4 | public string RexAvatarURL |
| 92 : | { | ||
| 93 : | get { return m_rexAvatarURL; } | ||
| 94 : | set | ||
| 95 : | { | ||
| 96 : | m_rexAvatarURL = value; | ||
| 97 : | if (OnRexAppearance != null) | ||
| 98 : | { | ||
| 99 : | OnRexAppearance(this); | ||
| 100 : | return; | ||
| 101 : | } | ||
| 102 : | } | ||
| 103 : | } | ||
| 104 : | |||
| 105 : | afrisby | 11 | /// <summary> |
| 106 : | /// Skype username of the avatar | ||
| 107 : | /// eg: Skypeuser | ||
| 108 : | /// </summary> | ||
| 109 : | afrisby | 4 | public string RexSkypeURL |
| 110 : | { | ||
| 111 : | get { return m_rexSkypeURL; } | ||
| 112 : | set { m_rexSkypeURL = value; } | ||
| 113 : | } | ||
| 114 : | |||
| 115 : | afrisby | 11 | /// <summary> |
| 116 : | /// The full Rex Username of this account | ||
| 117 : | /// Eg: user@hostname.com:10001 | ||
| 118 : | /// | ||
| 119 : | /// Note: This is not filled immedietely on | ||
| 120 : | /// creation. This property is filled in | ||
| 121 : | /// via Login and may not be availible | ||
| 122 : | /// immedietely upon connect. | ||
| 123 : | /// | ||
| 124 : | /// The above glitch is scheduled to be | ||
| 125 : | /// fixed by a new RexCommsManager which | ||
| 126 : | /// will allow this to be set at spawn in | ||
| 127 : | /// login. | ||
| 128 : | /// </summary> | ||
| 129 : | afrisby | 10 | public string RexAccount |
| 130 : | { | ||
| 131 : | get { return m_rexAccountID; } | ||
| 132 : | set | ||
| 133 : | { | ||
| 134 : | // Todo: More solid data checking here. | ||
| 135 : | m_rexAccountID = value; | ||
| 136 : | RexAuthURL = m_rexAccountID.Split('@')[1]; | ||
| 137 : | } | ||
| 138 : | } | ||
| 139 : | |||
| 140 : | afrisby | 11 | /// <summary> |
| 141 : | /// The URL of the Avatar's Authentication Server | ||
| 142 : | /// Eg: http://authentication.com:10001/ | ||
| 143 : | /// </summary> | ||
| 144 : | afrisby | 4 | public string RexAuthURL |
| 145 : | { | ||
| 146 : | get { return m_rexAuthURL; } | ||
| 147 : | set | ||
| 148 : | { | ||
| 149 : | m_rexAuthURL = value; | ||
| 150 : | |||
| 151 : | // Request Agent Properties Asynchronously | ||
| 152 : | ThreadPool.QueueUserWorkItem(RequestProperties); | ||
| 153 : | } | ||
| 154 : | } | ||
| 155 : | |||
| 156 : | afrisby | 11 | /// <summary> |
| 157 : | /// Special - used to convert GenericMessage packets | ||
| 158 : | /// to their appropriate Rex equivilents. | ||
| 159 : | /// | ||
| 160 : | /// Eg: GenericMessage(RexAppearance) -> | ||
| 161 : | /// OnRexAppearance(...) | ||
| 162 : | /// </summary> | ||
| 163 : | afrisby | 2 | void RealXtendClientView_OnGenericMessage(object sender, string method, List<string> args) |
| 164 : | { | ||
| 165 : | //TODO: Convert to Dictionary<Method, GenericMessageHandler> | ||
| 166 : | |||
| 167 : | if (method == "RexAppearance") | ||
| 168 : | if (OnRexAppearance != null) | ||
| 169 : | { | ||
| 170 : | OnRexAppearance(this); | ||
| 171 : | return; | ||
| 172 : | } | ||
| 173 : | |||
| 174 : | afrisby | 4 | if (method == "RexFaceExpression") |
| 175 : | afrisby | 2 | { |
| 176 : | afrisby | 4 | if (OnRexFaceExpression != null) |
| 177 : | afrisby | 2 | { |
| 178 : | OnRexFaceExpression(this, args); | ||
| 179 : | afrisby | 5 | return; |
| 180 : | afrisby | 2 | } |
| 181 : | } | ||
| 182 : | afrisby | 5 | |
| 183 : | if (method == "RexAvatarProp") | ||
| 184 : | { | ||
| 185 : | if(OnRexAvatarProperties != null) | ||
| 186 : | { | ||
| 187 : | OnRexAvatarProperties(this, args); | ||
| 188 : | return; | ||
| 189 : | } | ||
| 190 : | } | ||
| 191 : | |||
| 192 : | m_log.Warn("[REXCLIENTVIEW] Unhandled GenericMessage (" + method + ") {"); | ||
| 193 : | foreach (string s in args) | ||
| 194 : | { | ||
| 195 : | m_log.Warn("\t" + s); | ||
| 196 : | } | ||
| 197 : | m_log.Warn("}"); | ||
| 198 : | |||
| 199 : | afrisby | 2 | } |
| 200 : | |||
| 201 : | afrisby | 11 | /// <summary> |
| 202 : | /// Sends a Rex Script Command to the viewer | ||
| 203 : | /// attached to this ClientView. | ||
| 204 : | /// | ||
| 205 : | /// If you are coding something, try use | ||
| 206 : | /// SendRex*** instead, as many of them | ||
| 207 : | /// will trigger this instead with type | ||
| 208 : | /// and parameter checking. | ||
| 209 : | /// </summary> | ||
| 210 : | afrisby | 5 | public void SendRexScriptCommand(string unit, string command, string parameters) |
| 211 : | { | ||
| 212 : | List<string> pack = new List<string>(); | ||
| 213 : | |||
| 214 : | pack.Add(unit); | ||
| 215 : | pack.Add(command); | ||
| 216 : | |||
| 217 : | if (!string.IsNullOrEmpty(parameters)) | ||
| 218 : | pack.Add(parameters); | ||
| 219 : | |||
| 220 : | SendGenericMessage("RexScr", pack); | ||
| 221 : | } | ||
| 222 : | |||
| 223 : | public void SendRexInventoryMessage(string message) | ||
| 224 : | { | ||
| 225 : | SendRexScriptCommand("hud", "ShowInventoryMessage(\"" + message + "\")", ""); | ||
| 226 : | } | ||
| 227 : | |||
| 228 : | afrisby | 6 | public void SendRexScrollMessage(string message, double time) |
| 229 : | { | ||
| 230 : | SendRexScriptCommand("hud", "ShowScrollMessage(\"" + message + "\", \"" + time + "\")", ""); | ||
| 231 : | } | ||
| 232 : | |||
| 233 : | public void SendRexTutorialMessage(string message, double time) | ||
| 234 : | { | ||
| 235 : | SendRexScriptCommand("hud", "ShowScrollMessage(\"" + message + "\", \"" + time + "\")", ""); | ||
| 236 : | } | ||
| 237 : | |||
| 238 : | public void SendRexFadeInAndOut(string message, double between, double time) | ||
| 239 : | { | ||
| 240 : | SendRexScriptCommand("hud", | ||
| 241 : | "ShowInventoryMessage(\"" + message + "\"," | ||
| 242 : | + " \"" + between + "\", \"" + time + "\")", ""); | ||
| 243 : | } | ||
| 244 : | |||
| 245 : | |||
| 246 : | afrisby | 2 | public void SendRexFaceExpression(List<string> expressionData) |
| 247 : | { | ||
| 248 : | expressionData.Insert(0, AgentId.ToString()); | ||
| 249 : | SendGenericMessage("RexFaceExpression", expressionData); | ||
| 250 : | } | ||
| 251 : | |||
| 252 : | public void SendRexAppearance(UUID agentID, string avatarURL) | ||
| 253 : | { | ||
| 254 : | List<string> pack = new List<string>(); | ||
| 255 : | pack.Add(avatarURL); | ||
| 256 : | pack.Add(agentID.ToString()); | ||
| 257 : | |||
| 258 : | SendGenericMessage("RexAppearance", pack); | ||
| 259 : | } | ||
| 260 : | afrisby | 4 | |
| 261 : | /// <summary> | ||
| 262 : | /// Requests properties about this agent from their | ||
| 263 : | /// authentication server. This should be run in | ||
| 264 : | /// an async thread. | ||
| 265 : | /// | ||
| 266 : | /// Note that this particular function may set the | ||
| 267 : | /// avatars appearance which may in turn call | ||
| 268 : | /// additional modules and functions elsewhere. | ||
| 269 : | /// </summary> | ||
| 270 : | /// <param name="o"></param> | ||
| 271 : | private void RequestProperties(object o) | ||
| 272 : | { | ||
| 273 : | m_log.Info("[REXCLIENT] Resolving avatar..."); | ||
| 274 : | Hashtable ReqVals = new Hashtable(); | ||
| 275 : | ReqVals["avatar_uuid"] = AgentId.ToString(); | ||
| 276 : | ReqVals["AuthenticationAddress"] = RexAuthURL; | ||
| 277 : | |||
| 278 : | ArrayList SendParams = new ArrayList(); | ||
| 279 : | SendParams.Add(ReqVals); | ||
| 280 : | |||
| 281 : | XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", SendParams); | ||
| 282 : | |||
| 283 : | m_log.Info("[REXCLIENT] Sending XMLRPC Request to " + RexAuthURL); | ||
| 284 : | XmlRpcResponse authreply = req.Send(RexAuthURL, 9000); | ||
| 285 : | string rexAsAddress = ((Hashtable)authreply.Value)["as_address"].ToString(); | ||
| 286 : | string rexSkypeURL = ((Hashtable)authreply.Value)["skype_url"].ToString(); | ||
| 287 : | UUID userID = new UUID(((Hashtable) authreply.Value)["uuid"].ToString()); | ||
| 288 : | |||
| 289 : | // Sanity check | ||
| 290 : | if (userID == AgentId) | ||
| 291 : | { | ||
| 292 : | RexAvatarURL = rexAsAddress; | ||
| 293 : | RexSkypeURL = rexSkypeURL; | ||
| 294 : | } | ||
| 295 : | } | ||
| 296 : | mikkopa | 12 | |
| 297 : | internal void SendRexFog(float vStart, float vEnd, float vR, float vG, float vB) | ||
| 298 : | { | ||
| 299 : | throw new System.NotImplementedException(); | ||
| 300 : | } | ||
| 301 : | |||
| 302 : | internal void SendRexWaterHeight(float vHeight) | ||
| 303 : | { | ||
| 304 : | throw new System.NotImplementedException(); | ||
| 305 : | } | ||
| 306 : | |||
| 307 : | internal void SendRexPostProcess(int vEffectId, bool vbToggle) | ||
| 308 : | { | ||
| 309 : | throw new System.NotImplementedException(); | ||
| 310 : | } | ||
| 311 : | |||
| 312 : | internal void SendRexRttCamera(int command, string name, UUID uUID, Vector3 pos, Vector3 lookat, int width, int height) | ||
| 313 : | { | ||
| 314 : | throw new System.NotImplementedException(); | ||
| 315 : | } | ||
| 316 : | |||
| 317 : | internal void SendRexViewport(int command, string name, float vX, float vY, float vWidth, float vHeight) | ||
| 318 : | { | ||
| 319 : | throw new System.NotImplementedException(); | ||
| 320 : | } | ||
| 321 : | |||
| 322 : | internal void SendRexToggleWindSound(bool vbToggle) | ||
| 323 : | { | ||
| 324 : | throw new System.NotImplementedException(); | ||
| 325 : | } | ||
| 326 : | |||
| 327 : | internal void SendRexCameraClientSideEffect(bool enable, UUID uUID, Vector3 pos, Quaternion rot) | ||
| 328 : | { | ||
| 329 : | throw new System.NotImplementedException(); | ||
| 330 : | } | ||
| 331 : | |||
| 332 : | internal void SendRexSetAmbientLight(Vector3 lightDir, Vector3 lightC, Vector3 ambientC) | ||
| 333 : | { | ||
| 334 : | throw new System.NotImplementedException(); | ||
| 335 : | } | ||
| 336 : | |||
| 337 : | internal void SendRexPlayFlashAnimation(UUID uUID, float left, float top, float right, float bottom, float timeToDeath) | ||
| 338 : | { | ||
| 339 : | throw new System.NotImplementedException(); | ||
| 340 : | } | ||
| 341 : | |||
| 342 : | internal void SendRexPreloadAvatarAssets(List<string> vAssetsList) | ||
| 343 : | { | ||
| 344 : | throw new System.NotImplementedException(); | ||
| 345 : | } | ||
| 346 : | |||
| 347 : | internal void SendRexForceFOV(float fov, bool enable) | ||
| 348 : | { | ||
| 349 : | throw new System.NotImplementedException(); | ||
| 350 : | } | ||
| 351 : | |||
| 352 : | internal void SendRexForceCamera(int forceMode, float minZoom, float maxZoom) | ||
| 353 : | { | ||
| 354 : | throw new System.NotImplementedException(); | ||
| 355 : | } | ||
| 356 : | |||
| 357 : | internal void SendRexSky(int type, string images, float curvature, float tiling) | ||
| 358 : | { | ||
| 359 : | throw new System.NotImplementedException(); | ||
| 360 : | } | ||
| 361 : | |||
| 362 : | internal void SendRexPreloadAssets(Dictionary<UUID, uint> tempassetlist) | ||
| 363 : | { | ||
| 364 : | throw new System.NotImplementedException(); | ||
| 365 : | } | ||
| 366 : | |||
| 367 : | internal void SendMediaURL(UUID assetId, string mediaURL, byte vRefreshRate) | ||
| 368 : | { | ||
| 369 : | throw new System.NotImplementedException(); | ||
| 370 : | } | ||
| 371 : | |||
| 372 : | internal void RexIKSendLimbTarget(UUID vAgentID, int vLimbId, Vector3 vDest, float vTimeToTarget, float vStayTime, float vConstraintAngle, string vStartAnim, string vTargetAnim, string vEndAnim) | ||
| 373 : | { | ||
| 374 : | throw new System.NotImplementedException(); | ||
| 375 : | } | ||
| 376 : | |||
| 377 : | public void SendRexAvatarAnimation(UUID agentID, string vAnimName, float vRate, float vFadeIn, float vFadeOut, int nRepeats, bool vbStopAnim) //rex | ||
| 378 : | { | ||
| 379 : | throw new System.NotImplementedException(); | ||
| 380 : | } | ||
| 381 : | |||
| 382 : | internal void SendRexAvatarMorph(UUID uUID, string vMorphName, float vWeight, float vTime) | ||
| 383 : | { | ||
| 384 : | throw new System.NotImplementedException(); | ||
| 385 : | } | ||
| 386 : | |||
| 387 : | internal void SendRexMeshAnimation(UUID uUID, string vAnimName, float vRate, bool vbLooped, bool vbStopAnim) | ||
| 388 : | { | ||
| 389 : | throw new System.NotImplementedException(); | ||
| 390 : | } | ||
| 391 : | |||
| 392 : | internal void SendRexClientSideEffect(string assetId, float vTimeUntilLaunch, float vTimeUntilDeath, Vector3 pos, Quaternion rot, float vSpeed) | ||
| 393 : | { | ||
| 394 : | throw new System.NotImplementedException(); | ||
| 395 : | } | ||
| 396 : | afrisby | 2 | } |
| 397 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

