Annotation of /trunk/ModularRex/RexNetwork/RexClientViewBase.cs
Parent Directory
|
Revision Log
Revision 64 -
(view)
(download)
Original Path: trunk/ModularRex/RexNetwork/RexClientView.cs
| 1 : | afrisby | 25 | using System; |
| 2 : | using System.Collections; | ||
| 3 : | afrisby | 4 | using System.Collections.Generic; |
| 4 : | afrisby | 2 | using System.Net; |
| 5 : | afrisby | 4 | using System.Reflection; |
| 6 : | using System.Threading; | ||
| 7 : | using log4net; | ||
| 8 : | afrisby | 25 | using ModularRex.RexFramework; |
| 9 : | afrisby | 4 | using Nwc.XmlRpc; |
| 10 : | afrisby | 2 | using OpenMetaverse; |
| 11 : | afrisby | 25 | using OpenMetaverse.Packets; |
| 12 : | afrisby | 2 | using OpenSim.Framework; |
| 13 : | using OpenSim.Framework.Communications.Cache; | ||
| 14 : | afrisby | 5 | using OpenSim.Region.ClientStack; |
| 15 : | afrisby | 2 | using OpenSim.Region.ClientStack.LindenUDP; |
| 16 : | |||
| 17 : | namespace ModularRex.RexNetwork | ||
| 18 : | { | ||
| 19 : | public delegate void RexAppearanceDelegate(RexClientView sender); | ||
| 20 : | mikkopa | 14 | public delegate void RexFaceExpressionDelegate(RexClientView sender, List<string> parameters); |
| 21 : | tuco | 50 | public delegate void RexAvatarPropertiesDelegate(RexClientView sender, List<string> parameters); |
| 22 : | public delegate void RexObjectPropertiesDelegate(RexClientView sender, UUID id, RexObjectProperties props); | ||
| 23 : | public delegate void RexStartUpDelegate(RexClientView remoteClient, UUID agentID, string status); | ||
| 24 : | public delegate void RexClientScriptCmdDelegate(RexClientView remoteClient, UUID agentID, List<string> parameters); | ||
| 25 : | mikkopa | 55 | public delegate void ReceiveRexMediaURL(IClientAPI remoteClient, UUID agentID, UUID itemID, string mediaURL, byte refreshRate); |
| 26 : | afrisby | 2 | |
| 27 : | afrisby | 11 | /// <summary> |
| 28 : | /// Inherits from LLClientView the majority of functionality | ||
| 29 : | /// Overrides and extends for Rex-specific functionality. | ||
| 30 : | /// | ||
| 31 : | /// In the case whereby functionality uses the same packets but differs | ||
| 32 : | /// between Rex and LL, you can use a override on those specific functions | ||
| 33 : | /// to overload the request. | ||
| 34 : | /// </summary> | ||
| 35 : | mikkopa | 61 | public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance, IClientMediaURL |
| 36 : | afrisby | 2 | { |
| 37 : | afrisby | 4 | private static readonly ILog m_log = |
| 38 : | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 39 : | |||
| 40 : | afrisby | 10 | private string m_rexAccountID; |
| 41 : | afrisby | 4 | private string m_rexAvatarURL; |
| 42 : | private string m_rexAuthURL; | ||
| 43 : | private string m_rexSkypeURL; | ||
| 44 : | mikkopa | 12 | public string AvatarStorageOverride; |
| 45 : | afrisby | 4 | |
| 46 : | mikkopa | 20 | public float RexCharacterSpeedMod = 1.0f; |
| 47 : | public float RexMovementSpeedMod = 1.0f; | ||
| 48 : | public float RexVertMovementSpeedMod = 1.0f; | ||
| 49 : | public bool RexWalkDisabled = false; | ||
| 50 : | public bool RexFlyDisabled = false; | ||
| 51 : | public bool RexSitDisabled = false; | ||
| 52 : | |||
| 53 : | afrisby | 2 | public event RexAppearanceDelegate OnRexAppearance; |
| 54 : | public event RexFaceExpressionDelegate OnRexFaceExpression; | ||
| 55 : | tuco | 50 | public event RexAvatarPropertiesDelegate OnRexAvatarProperties; |
| 56 : | public event RexObjectPropertiesDelegate OnRexObjectProperties; | ||
| 57 : | public event RexStartUpDelegate OnRexStartUp; | ||
| 58 : | public event RexClientScriptCmdDelegate OnRexClientScriptCmd; | ||
| 59 : | mikkopa | 55 | public event ReceiveRexMediaURL OnReceiveRexMediaURL; |
| 60 : | afrisby | 2 | |
| 61 : | tuco | 64 | public RexClientView(EndPoint remoteEP, IScene scene, IAssetCache assetCache, |
| 62 : | afrisby | 6 | LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
| 63 : | afrisby | 5 | UUID sessionId, uint circuitCode, EndPoint proxyEP, ClientStackUserSettings userSettings) |
| 64 : | afrisby | 2 | : base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 65 : | afrisby | 5 | sessionId, circuitCode, proxyEP, userSettings) |
| 66 : | afrisby | 2 | { |
| 67 : | afrisby | 11 | // Rex communication now occurs via GenericMessage |
| 68 : | // We have a special handler here below. | ||
| 69 : | mikkopa | 55 | AddGenericPacketHandlers(); |
| 70 : | afrisby | 25 | |
| 71 : | OnBinaryGenericMessage += RexClientView_BinaryGenericMessage; | ||
| 72 : | afrisby | 2 | OnGenericMessage += RealXtendClientView_OnGenericMessage; |
| 73 : | } | ||
| 74 : | |||
| 75 : | afrisby | 4 | public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, |
| 76 : | afrisby | 6 | LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
| 77 : | afrisby | 5 | UUID sessionId, uint circuitCode, EndPoint proxyEP, string rexAvatarURL, string rexAuthURL, ClientStackUserSettings userSettings) |
| 78 : | afrisby | 4 | : base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 79 : | afrisby | 5 | sessionId, circuitCode, proxyEP, userSettings) |
| 80 : | afrisby | 4 | { |
| 81 : | afrisby | 11 | // Rex communication now occurs via GenericMessage |
| 82 : | afrisby | 25 | // We need to register GenericMessage handlers |
| 83 : | afrisby | 4 | |
| 84 : | mikkopa | 55 | AddGenericPacketHandlers(); |
| 85 : | afrisby | 25 | |
| 86 : | OnBinaryGenericMessage += RexClientView_BinaryGenericMessage; | ||
| 87 : | |||
| 88 : | afrisby | 4 | RexAvatarURL = rexAvatarURL; |
| 89 : | RexAuthURL = rexAuthURL; | ||
| 90 : | } | ||
| 91 : | |||
| 92 : | mikkopa | 55 | private void AddGenericPacketHandlers() |
| 93 : | { | ||
| 94 : | AddGenericPacketHandler("RexAppearance", RealXtendClientView_OnGenericMessage); | ||
| 95 : | AddGenericPacketHandler("RexFaceExpression", RealXtendClientView_OnGenericMessage); | ||
| 96 : | AddGenericPacketHandler("RexAvatarProp", RealXtendClientView_OnGenericMessage); | ||
| 97 : | AddGenericPacketHandler("RexPrimData", RealXtendClientView_OnGenericMessage); | ||
| 98 : | AddGenericPacketHandler("RexData", RealXtendClientView_OnGenericMessage); | ||
| 99 : | AddGenericPacketHandler("RexMediaUrl", RealXtendClientView_OnGenericMessage); | ||
| 100 : | } | ||
| 101 : | |||
| 102 : | afrisby | 11 | /// <summary> |
| 103 : | /// Registers interfaces for IClientCore, | ||
| 104 : | /// every time you make a new Rex-specific | ||
| 105 : | /// Interface. Make sure to register it here. | ||
| 106 : | /// </summary> | ||
| 107 : | afrisby | 9 | protected override void RegisterInterfaces() |
| 108 : | { | ||
| 109 : | RegisterInterface<IClientRexAppearance>(this); | ||
| 110 : | RegisterInterface<IClientRexFaceExpression>(this); | ||
| 111 : | |||
| 112 : | afrisby | 25 | // Register our own class 'as-is' so it can be |
| 113 : | // used via IClientCore.Get<RexClientView>()... | ||
| 114 : | RegisterInterface(this); | ||
| 115 : | |||
| 116 : | afrisby | 9 | base.RegisterInterfaces(); |
| 117 : | } | ||
| 118 : | |||
| 119 : | afrisby | 11 | /// <summary> |
| 120 : | /// The avatar URL for this avatar | ||
| 121 : | /// Eg: http://avatar.com:10000/uuid/ | ||
| 122 : | /// </summary> | ||
| 123 : | afrisby | 4 | public string RexAvatarURL |
| 124 : | { | ||
| 125 : | get { return m_rexAvatarURL; } | ||
| 126 : | set | ||
| 127 : | { | ||
| 128 : | m_rexAvatarURL = value; | ||
| 129 : | if (OnRexAppearance != null) | ||
| 130 : | { | ||
| 131 : | OnRexAppearance(this); | ||
| 132 : | return; | ||
| 133 : | } | ||
| 134 : | } | ||
| 135 : | } | ||
| 136 : | |||
| 137 : | afrisby | 11 | /// <summary> |
| 138 : | /// Skype username of the avatar | ||
| 139 : | /// eg: Skypeuser | ||
| 140 : | /// </summary> | ||
| 141 : | afrisby | 4 | public string RexSkypeURL |
| 142 : | { | ||
| 143 : | get { return m_rexSkypeURL; } | ||
| 144 : | set { m_rexSkypeURL = value; } | ||
| 145 : | } | ||
| 146 : | |||
| 147 : | afrisby | 11 | /// <summary> |
| 148 : | /// The full Rex Username of this account | ||
| 149 : | /// Eg: user@hostname.com:10001 | ||
| 150 : | /// | ||
| 151 : | /// Note: This is not filled immedietely on | ||
| 152 : | /// creation. This property is filled in | ||
| 153 : | /// via Login and may not be availible | ||
| 154 : | /// immedietely upon connect. | ||
| 155 : | /// | ||
| 156 : | /// The above glitch is scheduled to be | ||
| 157 : | /// fixed by a new RexCommsManager which | ||
| 158 : | /// will allow this to be set at spawn in | ||
| 159 : | /// login. | ||
| 160 : | /// </summary> | ||
| 161 : | afrisby | 10 | public string RexAccount |
| 162 : | { | ||
| 163 : | get { return m_rexAccountID; } | ||
| 164 : | set | ||
| 165 : | { | ||
| 166 : | // Todo: More solid data checking here. | ||
| 167 : | m_rexAccountID = value; | ||
| 168 : | RexAuthURL = m_rexAccountID.Split('@')[1]; | ||
| 169 : | } | ||
| 170 : | } | ||
| 171 : | |||
| 172 : | afrisby | 11 | /// <summary> |
| 173 : | /// The URL of the Avatar's Authentication Server | ||
| 174 : | /// Eg: http://authentication.com:10001/ | ||
| 175 : | /// </summary> | ||
| 176 : | afrisby | 4 | public string RexAuthURL |
| 177 : | { | ||
| 178 : | get { return m_rexAuthURL; } | ||
| 179 : | set | ||
| 180 : | { | ||
| 181 : | mikkopa | 39 | m_rexAuthURL = value; |
| 182 : | |||
| 183 : | afrisby | 4 | // Request Agent Properties Asynchronously |
| 184 : | ThreadPool.QueueUserWorkItem(RequestProperties); | ||
| 185 : | } | ||
| 186 : | } | ||
| 187 : | |||
| 188 : | afrisby | 25 | void RexClientView_BinaryGenericMessage(Object sender, string method, byte[][] args) |
| 189 : | { | ||
| 190 : | if(method == "RexPrimData".ToLower()) | ||
| 191 : | { | ||
| 192 : | HandleRexPrimData(args); | ||
| 193 : | return; | ||
| 194 : | } | ||
| 195 : | } | ||
| 196 : | |||
| 197 : | private void HandleRexPrimData(byte[][] args) | ||
| 198 : | { | ||
| 199 : | int rpdLen = 0; | ||
| 200 : | int idx = 0; | ||
| 201 : | bool first = false; | ||
| 202 : | UUID id = UUID.Zero; | ||
| 203 : | |||
| 204 : | foreach (byte[] arg in args) | ||
| 205 : | { | ||
| 206 : | if(!first) | ||
| 207 : | { | ||
| 208 : | id = new UUID(Util.FieldToString(arg)); | ||
| 209 : | first = true; | ||
| 210 : | continue; | ||
| 211 : | } | ||
| 212 : | |||
| 213 : | rpdLen += arg.Length; | ||
| 214 : | } | ||
| 215 : | |||
| 216 : | first = false; | ||
| 217 : | byte[] rpdArray = new byte[rpdLen]; | ||
| 218 : | |||
| 219 : | foreach (byte[] arg in args) | ||
| 220 : | { | ||
| 221 : | if(!first) | ||
| 222 : | { | ||
| 223 : | first = true; | ||
| 224 : | continue; | ||
| 225 : | } | ||
| 226 : | |||
| 227 : | arg.CopyTo(rpdArray,idx); | ||
| 228 : | idx += arg.Length; | ||
| 229 : | } | ||
| 230 : | |||
| 231 : | if (OnRexObjectProperties != null) | ||
| 232 : | OnRexObjectProperties(this, id, new RexObjectProperties(rpdArray)); | ||
| 233 : | } | ||
| 234 : | |||
| 235 : | mikkopa | 55 | private Dictionary<string, RexAvatarPropertiesDelegate> m_genericMessageHandlers; |
| 236 : | |||
| 237 : | afrisby | 11 | /// <summary> |
| 238 : | /// Special - used to convert GenericMessage packets | ||
| 239 : | /// to their appropriate Rex equivilents. | ||
| 240 : | /// | ||
| 241 : | /// Eg: GenericMessage(RexAppearance) -> | ||
| 242 : | /// OnRexAppearance(...) | ||
| 243 : | /// </summary> | ||
| 244 : | afrisby | 2 | void RealXtendClientView_OnGenericMessage(object sender, string method, List<string> args) |
| 245 : | { | ||
| 246 : | //TODO: Convert to Dictionary<Method, GenericMessageHandler> | ||
| 247 : | mikkopa | 55 | //RexAvatarPropertiesDelegate method; |
| 248 : | //if (m_genericMessageHandlers.TryGetValue(method, out method)) | ||
| 249 : | //{ | ||
| 250 : | // method(this, args); | ||
| 251 : | // return; | ||
| 252 : | //} | ||
| 253 : | |||
| 254 : | afrisby | 2 | if (method == "RexAppearance") |
| 255 : | if (OnRexAppearance != null) | ||
| 256 : | { | ||
| 257 : | OnRexAppearance(this); | ||
| 258 : | return; | ||
| 259 : | } | ||
| 260 : | |||
| 261 : | afrisby | 4 | if (method == "RexFaceExpression") |
| 262 : | afrisby | 2 | { |
| 263 : | afrisby | 4 | if (OnRexFaceExpression != null) |
| 264 : | afrisby | 2 | { |
| 265 : | OnRexFaceExpression(this, args); | ||
| 266 : | afrisby | 5 | return; |
| 267 : | afrisby | 2 | } |
| 268 : | } | ||
| 269 : | afrisby | 5 | |
| 270 : | if (method == "RexAvatarProp") | ||
| 271 : | { | ||
| 272 : | if(OnRexAvatarProperties != null) | ||
| 273 : | { | ||
| 274 : | OnRexAvatarProperties(this, args); | ||
| 275 : | return; | ||
| 276 : | } | ||
| 277 : | } | ||
| 278 : | |||
| 279 : | afrisby | 25 | if(method == "RexData") |
| 280 : | { | ||
| 281 : | |||
| 282 : | } | ||
| 283 : | |||
| 284 : | mikkopa | 14 | if (method == "rexscr") |
| 285 : | { | ||
| 286 : | tuco | 50 | if (OnRexClientScriptCmd != null) |
| 287 : | mikkopa | 14 | { |
| 288 : | tuco | 50 | OnRexClientScriptCmd(this, AgentId, args); |
| 289 : | mikkopa | 43 | return; |
| 290 : | mikkopa | 14 | } |
| 291 : | } | ||
| 292 : | |||
| 293 : | if (method == "RexStartup") | ||
| 294 : | { | ||
| 295 : | tuco | 50 | if (OnRexStartUp != null) |
| 296 : | mikkopa | 14 | { |
| 297 : | tuco | 50 | OnRexStartUp(this, AgentId, args[0]); |
| 298 : | mikkopa | 43 | return; |
| 299 : | mikkopa | 14 | } |
| 300 : | } | ||
| 301 : | |||
| 302 : | mikkopa | 55 | if (method == "rexmediaurl") |
| 303 : | { | ||
| 304 : | TriggerOnReceivedRexMediaURL(this, args); | ||
| 305 : | return; | ||
| 306 : | } | ||
| 307 : | |||
| 308 : | afrisby | 5 | m_log.Warn("[REXCLIENTVIEW] Unhandled GenericMessage (" + method + ") {"); |
| 309 : | foreach (string s in args) | ||
| 310 : | { | ||
| 311 : | m_log.Warn("\t" + s); | ||
| 312 : | } | ||
| 313 : | m_log.Warn("}"); | ||
| 314 : | afrisby | 2 | } |
| 315 : | |||
| 316 : | mikkopa | 55 | private void TriggerOnReceivedRexMediaURL(IClientAPI sender, List<string> args) |
| 317 : | { | ||
| 318 : | mikkopa | 61 | try |
| 319 : | mikkopa | 55 | { |
| 320 : | mikkopa | 61 | foreach (string s in args) |
| 321 : | { | ||
| 322 : | m_log.Debug("[REXCLIENTVIEW] MediaURL: " + s); | ||
| 323 : | } | ||
| 324 : | mikkopa | 55 | |
| 325 : | mikkopa | 61 | UUID assetID = new UUID(args[0]); |
| 326 : | string mediaUrl = args[1]; | ||
| 327 : | byte refreshRate = Convert.ToByte(args[2]); | ||
| 328 : | mikkopa | 55 | |
| 329 : | mikkopa | 61 | if (OnReceiveRexMediaURL != null) |
| 330 : | { | ||
| 331 : | OnReceiveRexMediaURL(this, AgentId, assetID, mediaUrl, refreshRate); | ||
| 332 : | } | ||
| 333 : | } | ||
| 334 : | catch (Exception e) | ||
| 335 : | mikkopa | 55 | { |
| 336 : | mikkopa | 61 | m_log.ErrorFormat("[REXCLIENTVIEW] Error parseing incoming media url. Exception: ", e); |
| 337 : | mikkopa | 55 | } |
| 338 : | } | ||
| 339 : | |||
| 340 : | afrisby | 25 | public void SendRexObjectProperties(UUID id, RexObjectProperties x) |
| 341 : | { | ||
| 342 : | GenericMessagePacket gmp = new GenericMessagePacket(); | ||
| 343 : | gmp.MethodData.Method = Utils.StringToBytes("RexPrimData"); | ||
| 344 : | |||
| 345 : | byte[] temprexprimdata = x.GetRexPrimDataToBytes(); | ||
| 346 : | int numlines = 0; | ||
| 347 : | int i = 0; | ||
| 348 : | |||
| 349 : | if (temprexprimdata != null) | ||
| 350 : | { | ||
| 351 : | while (i <= temprexprimdata.Length) | ||
| 352 : | { | ||
| 353 : | numlines++; | ||
| 354 : | i += 200; | ||
| 355 : | } | ||
| 356 : | } | ||
| 357 : | |||
| 358 : | gmp.ParamList = new GenericMessagePacket.ParamListBlock[1 + numlines]; | ||
| 359 : | gmp.ParamList[0] = new GenericMessagePacket.ParamListBlock(); | ||
| 360 : | gmp.ParamList[0].Parameter = Utils.StringToBytes(id.ToString()); | ||
| 361 : | |||
| 362 : | for (i = 0; i < numlines; i++) | ||
| 363 : | { | ||
| 364 : | gmp.ParamList[i + 1] = new GenericMessagePacket.ParamListBlock(); | ||
| 365 : | |||
| 366 : | if ((temprexprimdata.Length - i * 200) < 200) | ||
| 367 : | { | ||
| 368 : | gmp.ParamList[i + 1].Parameter = new byte[temprexprimdata.Length - i * 200]; | ||
| 369 : | Buffer.BlockCopy(temprexprimdata, i * 200, gmp.ParamList[i + 1].Parameter, 0, temprexprimdata.Length - i * 200); | ||
| 370 : | } | ||
| 371 : | else | ||
| 372 : | { | ||
| 373 : | gmp.ParamList[i + 1].Parameter = new byte[200]; | ||
| 374 : | Buffer.BlockCopy(temprexprimdata, i * 200, gmp.ParamList[i + 1].Parameter, 0, 200); | ||
| 375 : | } | ||
| 376 : | } | ||
| 377 : | |||
| 378 : | // m_log.Warn("[REXDEBUG]: SendRexPrimData " + vPrimId.ToString()); | ||
| 379 : | OutPacket(gmp, ThrottleOutPacketType.Task); | ||
| 380 : | |||
| 381 : | } | ||
| 382 : | |||
| 383 : | afrisby | 11 | /// <summary> |
| 384 : | /// Sends a Rex Script Command to the viewer | ||
| 385 : | /// attached to this ClientView. | ||
| 386 : | /// | ||
| 387 : | /// If you are coding something, try use | ||
| 388 : | /// SendRex*** instead, as many of them | ||
| 389 : | /// will trigger this instead with type | ||
| 390 : | /// and parameter checking. | ||
| 391 : | /// </summary> | ||
| 392 : | afrisby | 5 | public void SendRexScriptCommand(string unit, string command, string parameters) |
| 393 : | { | ||
| 394 : | List<string> pack = new List<string>(); | ||
| 395 : | |||
| 396 : | pack.Add(unit); | ||
| 397 : | pack.Add(command); | ||
| 398 : | |||
| 399 : | if (!string.IsNullOrEmpty(parameters)) | ||
| 400 : | pack.Add(parameters); | ||
| 401 : | |||
| 402 : | SendGenericMessage("RexScr", pack); | ||
| 403 : | } | ||
| 404 : | |||
| 405 : | public void SendRexInventoryMessage(string message) | ||
| 406 : | { | ||
| 407 : | SendRexScriptCommand("hud", "ShowInventoryMessage(\"" + message + "\")", ""); | ||
| 408 : | } | ||
| 409 : | |||
| 410 : | afrisby | 6 | public void SendRexScrollMessage(string message, double time) |
| 411 : | { | ||
| 412 : | SendRexScriptCommand("hud", "ShowScrollMessage(\"" + message + "\", \"" + time + "\")", ""); | ||
| 413 : | } | ||
| 414 : | |||
| 415 : | public void SendRexTutorialMessage(string message, double time) | ||
| 416 : | { | ||
| 417 : | SendRexScriptCommand("hud", "ShowScrollMessage(\"" + message + "\", \"" + time + "\")", ""); | ||
| 418 : | } | ||
| 419 : | |||
| 420 : | public void SendRexFadeInAndOut(string message, double between, double time) | ||
| 421 : | { | ||
| 422 : | SendRexScriptCommand("hud", | ||
| 423 : | "ShowInventoryMessage(\"" + message + "\"," | ||
| 424 : | + " \"" + between + "\", \"" + time + "\")", ""); | ||
| 425 : | } | ||
| 426 : | |||
| 427 : | |||
| 428 : | afrisby | 2 | public void SendRexFaceExpression(List<string> expressionData) |
| 429 : | { | ||
| 430 : | expressionData.Insert(0, AgentId.ToString()); | ||
| 431 : | SendGenericMessage("RexFaceExpression", expressionData); | ||
| 432 : | } | ||
| 433 : | |||
| 434 : | public void SendRexAppearance(UUID agentID, string avatarURL) | ||
| 435 : | { | ||
| 436 : | List<string> pack = new List<string>(); | ||
| 437 : | pack.Add(avatarURL); | ||
| 438 : | pack.Add(agentID.ToString()); | ||
| 439 : | |||
| 440 : | SendGenericMessage("RexAppearance", pack); | ||
| 441 : | } | ||
| 442 : | afrisby | 4 | |
| 443 : | /// <summary> | ||
| 444 : | /// Requests properties about this agent from their | ||
| 445 : | /// authentication server. This should be run in | ||
| 446 : | /// an async thread. | ||
| 447 : | /// | ||
| 448 : | /// Note that this particular function may set the | ||
| 449 : | /// avatars appearance which may in turn call | ||
| 450 : | /// additional modules and functions elsewhere. | ||
| 451 : | /// </summary> | ||
| 452 : | /// <param name="o"></param> | ||
| 453 : | private void RequestProperties(object o) | ||
| 454 : | { | ||
| 455 : | m_log.Info("[REXCLIENT] Resolving avatar..."); | ||
| 456 : | Hashtable ReqVals = new Hashtable(); | ||
| 457 : | afrisby | 25 | ReqVals["avatar_account"] = RexAccount; |
| 458 : | afrisby | 4 | ReqVals["AuthenticationAddress"] = RexAuthURL; |
| 459 : | |||
| 460 : | ArrayList SendParams = new ArrayList(); | ||
| 461 : | SendParams.Add(ReqVals); | ||
| 462 : | |||
| 463 : | afrisby | 25 | XmlRpcRequest req = new XmlRpcRequest("get_user_by_account", SendParams); |
| 464 : | afrisby | 4 | |
| 465 : | afrisby | 25 | m_log.Info("[REXCLIENT] Sending XMLRPC Request to http://" + RexAuthURL); |
| 466 : | afrisby | 4 | |
| 467 : | afrisby | 25 | XmlRpcResponse authreply = req.Send("http://" + RexAuthURL, 9000); |
| 468 : | |||
| 469 : | mikkopa | 39 | //m_log.Info(authreply.ToString()); |
| 470 : | mikkopa | 28 | if (!((Hashtable)authreply.Value).ContainsKey("error_type")) |
| 471 : | { | ||
| 472 : | afrisby | 25 | string rexAsAddress = ((Hashtable)authreply.Value)["as_address"].ToString(); |
| 473 : | mikkopa | 39 | //string rexSkypeURL = ((Hashtable)authreply.Value)["skype_url"].ToString(); |
| 474 : | afrisby | 25 | UUID userID = new UUID(((Hashtable) authreply.Value)["uuid"].ToString()); |
| 475 : | |||
| 476 : | mikkopa | 14 | // Sanity check |
| 477 : | if (userID == AgentId) | ||
| 478 : | { | ||
| 479 : | RexAvatarURL = rexAsAddress; | ||
| 480 : | mikkopa | 39 | //RexSkypeURL = rexSkypeURL; |
| 481 : | mikkopa | 14 | } |
| 482 : | } | ||
| 483 : | else | ||
| 484 : | afrisby | 4 | { |
| 485 : | mikkopa | 28 | m_log.Warn("[REXCLIENT]: User not found"); |
| 486 : | afrisby | 4 | } |
| 487 : | } | ||
| 488 : | mikkopa | 12 | |
| 489 : | mikkopa | 20 | /// <summary> |
| 490 : | /// Sends Fog parameters to client. Only works underwater. | ||
| 491 : | /// </summary> | ||
| 492 : | /// <param name="start">meters from camera where the fog starts</param> | ||
| 493 : | /// <param name="end">meters from camera where the fog ends</param> | ||
| 494 : | /// <param name="red">redness in fog</param> | ||
| 495 : | /// <param name="green">greeness in fog</param> | ||
| 496 : | /// <param name="blue">blueness in fog</param> | ||
| 497 : | public void SendRexFog(float start, float end, float red, float green, float blue) | ||
| 498 : | mikkopa | 12 | { |
| 499 : | mikkopa | 20 | List<string> pack = new List<string>(); |
| 500 : | |||
| 501 : | pack.Add(start.ToString()); | ||
| 502 : | pack.Add(end.ToString()); | ||
| 503 : | pack.Add(red.ToString()); | ||
| 504 : | pack.Add(green.ToString()); | ||
| 505 : | pack.Add(blue.ToString()); | ||
| 506 : | |||
| 507 : | SendGenericMessage("RexFog", pack); | ||
| 508 : | mikkopa | 12 | } |
| 509 : | |||
| 510 : | mikkopa | 20 | /// <summary> |
| 511 : | /// Sends water height to client. Usually used when changing water height on the fly with scripting. | ||
| 512 : | /// </summary> | ||
| 513 : | /// <param name="height">Water height in meters</param> | ||
| 514 : | public void SendRexWaterHeight(float height) | ||
| 515 : | mikkopa | 12 | { |
| 516 : | mikkopa | 20 | List<string> pack = new List<string>(); |
| 517 : | |||
| 518 : | pack.Add(height.ToString()); | ||
| 519 : | |||
| 520 : | SendGenericMessage("RexWaterHeight", pack); | ||
| 521 : | mikkopa | 12 | } |
| 522 : | |||
| 523 : | mikkopa | 21 | /// <summary> |
| 524 : | /// Sends post postprosessing effect toggle to client. | ||
| 525 : | /// </summary> | ||
| 526 : | /// <see cref="http://rexdeveloper.org/wiki/index.php?title=Content_Scripting_Python_Post-Process"/> | ||
| 527 : | /// <param name="effectId">Id of the effect. See documentation for the effect ids</param> | ||
| 528 : | /// <param name="toggle">True to set effect on. False to set effect off.</param> | ||
| 529 : | public void SendRexPostProcess(int effectId, bool toggle) | ||
| 530 : | mikkopa | 12 | { |
| 531 : | mikkopa | 21 | List<string> pack = new List<string>(); |
| 532 : | |||
| 533 : | pack.Add(effectId.ToString()); | ||
| 534 : | pack.Add(toggle.ToString()); | ||
| 535 : | |||
| 536 : | SendGenericMessage("RexPostP", pack); | ||
| 537 : | mikkopa | 12 | } |
| 538 : | |||
| 539 : | mikkopa | 21 | /// <summary> |
| 540 : | /// Creates client side rtt camera | ||
| 541 : | /// </summary> | ||
| 542 : | /// <param name="command">0 to remove existing rtt camera (by name), 1 to add new rtt camera</param> | ||
| 543 : | /// <param name="name">Unique identifier for the camera</param> | ||
| 544 : | /// <param name="assetId">UUID of the texture that gets rendered to</param> | ||
| 545 : | /// <param name="pos">Position of the camera in the world</param> | ||
| 546 : | /// <param name="lookat">Point in the world the camera will look at</param> | ||
| 547 : | /// <param name="width">Width of the texture</param> | ||
| 548 : | /// <param name="height">Height of the texture</param> | ||
| 549 : | public void SendRexRttCamera(int command, string name, UUID assetId, Vector3 pos, Vector3 lookat, int width, int height) | ||
| 550 : | mikkopa | 12 | { |
| 551 : | mikkopa | 21 | List<string> pack = new List<string>(); |
| 552 : | |||
| 553 : | pack.Add(command.ToString()); | ||
| 554 : | pack.Add(name); | ||
| 555 : | pack.Add(assetId.ToString()); | ||
| 556 : | pack.Add(pos.ToString()); | ||
| 557 : | pack.Add(lookat.ToString()); | ||
| 558 : | pack.Add(width.ToString()); | ||
| 559 : | pack.Add(height.ToString()); | ||
| 560 : | |||
| 561 : | SendGenericMessage("RexRttCam", pack); | ||
| 562 : | mikkopa | 12 | } |
| 563 : | |||
| 564 : | mikkopa | 21 | /// <summary> |
| 565 : | /// Sends a viewport to client | ||
| 566 : | /// </summary> | ||
| 567 : | /// <param name="command">0 to remove existing viewport (by name), 1 to add new viewport.</param> | ||
| 568 : | /// <param name="name">Unique identifier for the viewport</param> | ||
| 569 : | /// <param name="posX">screen relative position of the left edge of the viewport</param> | ||
| 570 : | /// <param name="posY">screen relative position of the top edge of the viewport</param> | ||
| 571 : | /// <param name="width">screen relative width of the viewport</param> | ||
| 572 : | /// <param name="height">screen relative height of the viewport</param> | ||
| 573 : | public void SendRexViewport(int command, string name, float posX, float posY, float width, float height) | ||
| 574 : | mikkopa | 12 | { |
| 575 : | mikkopa | 21 | List<string> pack = new List<string>(); |
| 576 : | |||
| 577 : | pack.Add(command.ToString()); | ||
| 578 : | pack.Add(name); | ||
| 579 : | pack.Add(posX.ToString()); | ||
| 580 : | pack.Add(posY.ToString()); | ||
| 581 : | pack.Add(width.ToString()); | ||
| 582 : | pack.Add(height.ToString()); | ||
| 583 : | |||
| 584 : | SendGenericMessage("RexSetViewport", pack); | ||
| 585 : | mikkopa | 12 | } |
| 586 : | |||
| 587 : | mikkopa | 21 | /// <summary> |
| 588 : | /// Toggles the wind sound on client | ||
| 589 : | /// </summary> | ||
| 590 : | /// <param name="toggle"></param> | ||
| 591 : | public void SendRexToggleWindSound(bool toggle) | ||
| 592 : | mikkopa | 12 | { |
| 593 : | mikkopa | 21 | List<string> pack = new List<string>(); |
| 594 : | |||
| 595 : | pack.Add(toggle.ToString()); | ||
| 596 : | |||
| 597 : | SendGenericMessage("RexToggleWindSound", pack); | ||
| 598 : | mikkopa | 12 | } |
| 599 : | |||
| 600 : | mikkopa | 21 | /// <summary> |
| 601 : | /// Sends Rex clientside camera effects, particle script attached to camera etc. | ||
| 602 : | /// </summary> | ||
| 603 : | /// <param name="enable">True to enable the effect, False to disable</param> | ||
| 604 : | /// <param name="assetId">Id of the effect</param> | ||
| 605 : | /// <param name="pos">Offset position from the camera</param> | ||
| 606 : | /// <param name="rot">Offset rotation from the camera</param> | ||
| 607 : | public void SendRexCameraClientSideEffect(bool enable, UUID assetId, Vector3 pos, Quaternion rot) | ||
| 608 : | mikkopa | 12 | { |
| 609 : | mikkopa | 21 | List<string> pack = new List<string>(); |
| 610 : | |||
| 611 : | pack.Add(assetId.ToString()); | ||
| 612 : | pack.Add(pos.ToString()); | ||
| 613 : | pack.Add(rot.ToString()); | ||
| 614 : | pack.Add(enable.ToString()); | ||
| 615 : | |||
| 616 : | SendGenericMessage("RexSCSEffect", pack); | ||
| 617 : | mikkopa | 12 | } |
| 618 : | |||
| 619 : | mikkopa | 21 | /// <summary> |
| 620 : | /// Overrides default lighting conditions and ambient light in the world. | ||
| 621 : | /// | ||
| 622 : | /// Note that this override is a hard one. The user will be unable to change the lighting | ||
| 623 : | /// conditions in any way after they are overridden. | ||
| 624 : | /// </summary> | ||
| 625 : | /// <param name="direction">Direction of the global light (sun)</param> | ||
| 626 : | /// <param name="colour">Colour of the global light</param> | ||
| 627 : | /// <param name="ambientColour">Colour of the ambient light (the light that is always present)</param> | ||
| 628 : | public void SendRexSetAmbientLight(Vector3 direction, Vector3 colour, Vector3 ambientColour) | ||
| 629 : | mikkopa | 12 | { |
| 630 : | mikkopa | 21 | List<string> pack = new List<string>(); |
| 631 : | |||
| 632 : | pack.Add(direction.ToString()); | ||
| 633 : | pack.Add(colour.ToString()); | ||
| 634 : | pack.Add(ambientColour.ToString()); | ||
| 635 : | |||
| 636 : | SendGenericMessage("RexAmbientL", pack); | ||
| 637 : | mikkopa | 12 | } |
| 638 : | |||
| 639 : | mikkopa | 21 | /// <summary> |
| 640 : | /// Lauch flash animation to play on client | ||
| 641 : | /// </summary> | ||
| 642 : | /// <param name="assetId">Id of the flash animation (swf) to play</param> | ||
| 643 : | /// <param name="left">left border of the rectangle</param> | ||
| 644 : | /// <param name="top">top border of the rectangle</param> | ||
| 645 : | /// <param name="right">right border of the rectangle</param> | ||
| 646 : | /// <param name="bottom">bottom border of the rectangle</param> | ||
| 647 : | /// <param name="timeToDeath">time in seconds from start of animation playback until the flash control is destroyed</param> | ||
| 648 : | public void SendRexPlayFlashAnimation(UUID assetId, float left, float top, float right, float bottom, float timeToDeath) | ||
| 649 : | mikkopa | 12 | { |
| 650 : | mikkopa | 21 | List<string> pack = new List<string>(); |
| 651 : | |||
| 652 : | pack.Add(assetId.ToString()); | ||
| 653 : | pack.Add(left.ToString()); | ||
| 654 : | pack.Add(top.ToString()); | ||
| 655 : | pack.Add(right.ToString()); | ||
| 656 : | pack.Add(bottom.ToString()); | ||
| 657 : | pack.Add(timeToDeath.ToString()); | ||
| 658 : | |||
| 659 : | SendGenericMessage("RexFlashAnim", pack); | ||
| 660 : | mikkopa | 12 | } |
| 661 : | |||
| 662 : | internal void SendRexPreloadAvatarAssets(List<string> vAssetsList) | ||
| 663 : | { | ||
| 664 : | throw new System.NotImplementedException(); | ||
| 665 : | } | ||
| 666 : | |||
| 667 : | mikkopa | 45 | /// <summary> |
| 668 : | /// Force Field Of View | ||
| 669 : | /// </summary> | ||
| 670 : | /// <param name="fov">Field of View in degrees. This parameter is irrelevant when disabling FOV</param> | ||
| 671 : | /// <param name="enable">True to enable, False to disable</param> | ||
| 672 : | public void SendRexForceFOV(float fov, bool enable) | ||
| 673 : | mikkopa | 12 | { |
| 674 : | mikkopa | 45 | List<string> pack = new List<string>(); |
| 675 : | |||
| 676 : | pack.Add(fov.ToString()); | ||
| 677 : | pack.Add(enable.ToString()); | ||
| 678 : | |||
| 679 : | SendGenericMessage("RexForceFOV", pack); | ||
| 680 : | mikkopa | 12 | } |
| 681 : | |||
| 682 : | mikkopa | 45 | /// <summary> |
| 683 : | /// Sends Forced Camera mode to client | ||
| 684 : | /// </summary> | ||
| 685 : | /// <param name="forceMode">1 = 1st person mode, 3 = 3rd person mode, 0 = no limits</param> | ||
| 686 : | /// <param name="minZoom">Minimum zoom (0.0-1.0)</param> | ||
| 687 : | /// <param name="maxZoom">Maximum zoom (0.0-1.0)</param> | ||
| 688 : | public void SendRexForceCamera(int forceMode, float minZoom, float maxZoom) | ||
| 689 : | mikkopa | 12 | { |
| 690 : | mikkopa | 45 | List<string> pack = new List<string>(); |
| 691 : | |||
| 692 : | pack.Add(forceMode.ToString()); | ||
| 693 : | pack.Add(minZoom.ToString()); | ||
| 694 : | pack.Add(maxZoom.ToString()); | ||
| 695 : | |||
| 696 : | SendGenericMessage("RexForceCamera", pack); | ||
| 697 : | mikkopa | 12 | } |
| 698 : | |||
| 699 : | mikkopa | 45 | /// <summary> |
| 700 : | /// Sends the sky to user | ||
| 701 : | /// </summary> | ||
| 702 : | /// <param name="type">Type of the sky: 0 = none, 1 = skybox, 2 = skydome</param> | ||
| 703 : | /// <param name="images">List of image uuids - separated by space - to use for the sky. | ||
| 704 : | /// Skyboxes need 6 images, skydomes take one image. | ||
| 705 : | /// You can add suffix to the uuids to specify which side the texture should go to: | ||
| 706 : | /// _fr front, _lf left, _rt right, _bk back, _up up, _dn down </param> | ||
| 707 : | /// <param name="curvature">Curvature of the skydome. Values around 10.0 are good for | ||
| 708 : | /// open spaces and landscapes. Not used with skyboxes</param> | ||
| 709 : | /// <param name="tiling">Skydome tiling. Not used with skyboxes.</param> | ||
| 710 : | public void SendRexSky(int type, string images, float curvature, float tiling) | ||
| 711 : | mikkopa | 12 | { |
| 712 : | mikkopa | 45 | List<string> pack = new List<string>(); |
| 713 : | |||
| 714 : | pack.Add(type.ToString()); | ||
| 715 : | pack.Add(images); | ||
| 716 : | pack.Add(curvature.ToString()); | ||
| 717 : | pack.Add(tiling.ToString()); | ||
| 718 : | |||
| 719 : | SendGenericMessage("RexSky", pack); | ||
| 720 : | mikkopa | 12 | } |
| 721 : | |||
| 722 : | internal void SendRexPreloadAssets(Dictionary<UUID, uint> tempassetlist) | ||
| 723 : | { | ||
| 724 : | throw new System.NotImplementedException(); | ||
| 725 : | } | ||
| 726 : | |||
| 727 : | mikkopa | 45 | /// <summary> |
| 728 : | /// Sends MediaURL to client | ||
| 729 : | /// </summary> | ||
| 730 : | /// <param name="assetId">UUID of the asset which to replace with MediaURL content</param> | ||
| 731 : | /// <param name="mediaURL">URL pointing to web-page or vnc server</param> | ||
| 732 : | /// <param name="refreshRate">How many times per second to refresh the texture</param> | ||
| 733 : | public void SendMediaURL(UUID assetId, string mediaURL, byte refreshRate) | ||
| 734 : | mikkopa | 12 | { |
| 735 : | mikkopa | 61 | if (mediaURL == null) |
| 736 : | { | ||
| 737 : | m_log.Warn("[REXCLIENTVIEW]: Did not send media url to user, because it was null"); | ||
| 738 : | mikkopa | 55 | return; |
| 739 : | mikkopa | 61 | } |
| 740 : | mikkopa | 45 | List<string> pack = new List<string>(); |
| 741 : | |||
| 742 : | pack.Add(assetId.ToString()); | ||
| 743 : | pack.Add(mediaURL); | ||
| 744 : | pack.Add(refreshRate.ToString()); | ||
| 745 : | |||
| 746 : | SendGenericMessage("RexMediaUrl", pack); | ||
| 747 : | mikkopa | 12 | } |
| 748 : | |||
| 749 : | mikkopa | 45 | public void RexIKSendLimbTarget(UUID agentID, int limbId, Vector3 destination, float timeToTarget, |
| 750 : | float stayTime, float constraintAngle, string startAnim, string targetAnim, string endAnim) | ||
| 751 : | mikkopa | 12 | { |
| 752 : | mikkopa | 45 | List<string> pack = new List<string>(); |
| 753 : | |||
| 754 : | pack.Add("0"); | ||
| 755 : | pack.Add(agentID.ToString()); | ||
| 756 : | pack.Add(limbId.ToString()); | ||
| 757 : | string sDest = destination.X.ToString() + " " + destination.Y.ToString() + " " + destination.Z.ToString(); | ||
| 758 : | sDest = sDest.Replace(",", "."); | ||
| 759 : | pack.Add(sDest); | ||
| 760 : | pack.Add(timeToTarget.ToString()); | ||
| 761 : | pack.Add(stayTime.ToString()); | ||
| 762 : | pack.Add(constraintAngle.ToString()); | ||
| 763 : | pack.Add(startAnim); | ||
| 764 : | pack.Add(targetAnim); | ||
| 765 : | pack.Add(endAnim); | ||
| 766 : | |||
| 767 : | SendGenericMessage("RexIK", pack); | ||
| 768 : | mikkopa | 12 | } |
| 769 : | |||
| 770 : | mikkopa | 45 | public void SendRexAvatarAnimation(UUID agentID, string animName, float rate, float fadeIn, |
| 771 : | float fadeOut, int repeats, bool stopAnim) | ||
| 772 : | mikkopa | 12 | { |
| 773 : | mikkopa | 45 | List<string> pack = new List<string>(); |
| 774 : | |||
| 775 : | pack.Add(agentID.ToString()); | ||
| 776 : | pack.Add(animName); | ||
| 777 : | pack.Add(rate.ToString()); | ||
| 778 : | pack.Add(fadeIn.ToString().Replace(",",".")); | ||
| 779 : | pack.Add(fadeOut.ToString().Replace(",", ".")); | ||
| 780 : | pack.Add(repeats.ToString()); | ||
| 781 : | pack.Add(stopAnim.ToString()); | ||
| 782 : | |||
| 783 : | SendGenericMessage("RexAnim", pack); | ||
| 784 : | mikkopa | 12 | } |
| 785 : | |||
| 786 : | mikkopa | 45 | public void SendRexAvatarMorph(UUID agentID, string morphName, float weight, float time) |
| 787 : | mikkopa | 12 | { |
| 788 : | mikkopa | 45 | List<string> pack = new List<string>(); |
| 789 : | |||
| 790 : | pack.Add(agentID.ToString()); | ||
| 791 : | pack.Add(morphName); | ||
| 792 : | pack.Add(weight.ToString()); | ||
| 793 : | pack.Add(time.ToString()); | ||
| 794 : | |||
| 795 : | SendGenericMessage("RexMorph", pack); | ||
| 796 : | mikkopa | 12 | } |
| 797 : | |||
| 798 : | internal void SendRexMeshAnimation(UUID uUID, string vAnimName, float vRate, bool vbLooped, bool vbStopAnim) | ||
| 799 : | { | ||
| 800 : | throw new System.NotImplementedException(); | ||
| 801 : | } | ||
| 802 : | |||
| 803 : | internal void SendRexClientSideEffect(string assetId, float vTimeUntilLaunch, float vTimeUntilDeath, Vector3 pos, Quaternion rot, float vSpeed) | ||
| 804 : | { | ||
| 805 : | throw new System.NotImplementedException(); | ||
| 806 : | } | ||
| 807 : | afrisby | 2 | } |
| 808 : | afrisby | 25 | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

