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

