| 1 |
using System.Collections; |
using System; |
| 2 |
|
using System.Collections; |
| 3 |
using System.Collections.Generic; |
using System.Collections.Generic; |
| 4 |
using System.Net; |
using System.Net; |
| 5 |
using System.Reflection; |
using System.Reflection; |
| 6 |
using System.Threading; |
using System.Threading; |
| 7 |
using log4net; |
using log4net; |
| 8 |
|
using ModularRex.RexFramework; |
| 9 |
using Nwc.XmlRpc; |
using Nwc.XmlRpc; |
| 10 |
using OpenMetaverse; |
using OpenMetaverse; |
| 11 |
|
using OpenMetaverse.Packets; |
| 12 |
using OpenSim.Framework; |
using OpenSim.Framework; |
| 13 |
using OpenSim.Framework.Communications.Cache; |
using OpenSim.Framework.Communications.Cache; |
| 14 |
using OpenSim.Region.ClientStack; |
using OpenSim.Region.ClientStack; |
| 22 |
|
|
| 23 |
public delegate void RexAvatarProperties(RexClientView sender, List<string> parameters); |
public delegate void RexAvatarProperties(RexClientView sender, List<string> parameters); |
| 24 |
|
|
| 25 |
|
public delegate void RexRecieveObjectPropertiesDelegate(RexClientView sender, UUID id, RexObjectProperties props); |
| 26 |
|
|
| 27 |
public delegate void ReceiveRexStartUp(RexClientView remoteClient, UUID agentID, string status); |
public delegate void ReceiveRexStartUp(RexClientView remoteClient, UUID agentID, string status); |
| 28 |
|
|
| 29 |
public delegate void ReceiveRexClientScriptCmd(RexClientView remoteClient, UUID agentID, List<string> parameters); |
public delegate void ReceiveRexClientScriptCmd(RexClientView remoteClient, UUID agentID, List<string> parameters); |
| 57 |
public event RexAppearanceDelegate OnRexAppearance; |
public event RexAppearanceDelegate OnRexAppearance; |
| 58 |
public event RexFaceExpressionDelegate OnRexFaceExpression; |
public event RexFaceExpressionDelegate OnRexFaceExpression; |
| 59 |
public event RexAvatarProperties OnRexAvatarProperties; |
public event RexAvatarProperties OnRexAvatarProperties; |
| 60 |
|
public event RexRecieveObjectPropertiesDelegate OnRexObjectProperties; |
| 61 |
public event ReceiveRexStartUp OnReceiveRexStartUp; |
public event ReceiveRexStartUp OnReceiveRexStartUp; |
| 62 |
public event ReceiveRexClientScriptCmd OnReceiveRexClientScriptCmd; |
public event ReceiveRexClientScriptCmd OnReceiveRexClientScriptCmd; |
| 63 |
|
|
| 69 |
{ |
{ |
| 70 |
// Rex communication now occurs via GenericMessage |
// Rex communication now occurs via GenericMessage |
| 71 |
// We have a special handler here below. |
// We have a special handler here below. |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
AddGenericPacketHandler("RexAppearance", RealXtendClientView_OnGenericMessage); |
| 75 |
|
AddGenericPacketHandler("RexFaceExpression", RealXtendClientView_OnGenericMessage); |
| 76 |
|
AddGenericPacketHandler("RexAvatarProp", RealXtendClientView_OnGenericMessage); |
| 77 |
|
AddGenericPacketHandler("RexPrimData", RealXtendClientView_OnGenericMessage); |
| 78 |
|
AddGenericPacketHandler("RexData", RealXtendClientView_OnGenericMessage); |
| 79 |
|
|
| 80 |
|
OnBinaryGenericMessage += RexClientView_BinaryGenericMessage; |
| 81 |
OnGenericMessage += RealXtendClientView_OnGenericMessage; |
OnGenericMessage += RealXtendClientView_OnGenericMessage; |
| 82 |
} |
} |
| 83 |
|
|
| 88 |
sessionId, circuitCode, proxyEP, userSettings) |
sessionId, circuitCode, proxyEP, userSettings) |
| 89 |
{ |
{ |
| 90 |
// Rex communication now occurs via GenericMessage |
// Rex communication now occurs via GenericMessage |
| 91 |
// We have a special handler here below. |
// We need to register GenericMessage handlers |
| 92 |
OnGenericMessage += RealXtendClientView_OnGenericMessage; |
|
| 93 |
|
AddGenericPacketHandler("RexAppearance", RealXtendClientView_OnGenericMessage); |
| 94 |
|
AddGenericPacketHandler("RexFaceExpression", RealXtendClientView_OnGenericMessage); |
| 95 |
|
AddGenericPacketHandler("RexAvatarProp", RealXtendClientView_OnGenericMessage); |
| 96 |
|
AddGenericPacketHandler("RexPrimData", RealXtendClientView_OnGenericMessage); |
| 97 |
|
AddGenericPacketHandler("RexData", RealXtendClientView_OnGenericMessage); |
| 98 |
|
|
| 99 |
|
OnBinaryGenericMessage += RexClientView_BinaryGenericMessage; |
| 100 |
|
|
| 101 |
RexAvatarURL = rexAvatarURL; |
RexAvatarURL = rexAvatarURL; |
| 102 |
RexAuthURL = rexAuthURL; |
RexAuthURL = rexAuthURL; |
| 111 |
{ |
{ |
| 112 |
RegisterInterface<IClientRexAppearance>(this); |
RegisterInterface<IClientRexAppearance>(this); |
| 113 |
RegisterInterface<IClientRexFaceExpression>(this); |
RegisterInterface<IClientRexFaceExpression>(this); |
| 114 |
RegisterInterface<RexClientView>(this); |
|
| 115 |
|
// Register our own class 'as-is' so it can be |
| 116 |
|
// used via IClientCore.Get<RexClientView>()... |
| 117 |
|
RegisterInterface(this); |
| 118 |
|
|
| 119 |
base.RegisterInterfaces(); |
base.RegisterInterfaces(); |
| 120 |
} |
} |
| 194 |
} |
} |
| 195 |
} |
} |
| 196 |
|
|
| 197 |
|
void RexClientView_BinaryGenericMessage(Object sender, string method, byte[][] args) |
| 198 |
|
{ |
| 199 |
|
if(method == "RexPrimData".ToLower()) |
| 200 |
|
{ |
| 201 |
|
HandleRexPrimData(args); |
| 202 |
|
return; |
| 203 |
|
} |
| 204 |
|
} |
| 205 |
|
|
| 206 |
|
private void HandleRexPrimData(byte[][] args) |
| 207 |
|
{ |
| 208 |
|
int rpdLen = 0; |
| 209 |
|
int idx = 0; |
| 210 |
|
bool first = false; |
| 211 |
|
UUID id = UUID.Zero; |
| 212 |
|
|
| 213 |
|
foreach (byte[] arg in args) |
| 214 |
|
{ |
| 215 |
|
if(!first) |
| 216 |
|
{ |
| 217 |
|
id = new UUID(Util.FieldToString(arg)); |
| 218 |
|
first = true; |
| 219 |
|
continue; |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
rpdLen += arg.Length; |
| 223 |
|
} |
| 224 |
|
|
| 225 |
|
first = false; |
| 226 |
|
byte[] rpdArray = new byte[rpdLen]; |
| 227 |
|
|
| 228 |
|
foreach (byte[] arg in args) |
| 229 |
|
{ |
| 230 |
|
if(!first) |
| 231 |
|
{ |
| 232 |
|
first = true; |
| 233 |
|
continue; |
| 234 |
|
} |
| 235 |
|
|
| 236 |
|
arg.CopyTo(rpdArray,idx); |
| 237 |
|
idx += arg.Length; |
| 238 |
|
} |
| 239 |
|
|
| 240 |
|
if (OnRexObjectProperties != null) |
| 241 |
|
OnRexObjectProperties(this, id, new RexObjectProperties(rpdArray)); |
| 242 |
|
} |
| 243 |
|
|
| 244 |
/// <summary> |
/// <summary> |
| 245 |
/// Special - used to convert GenericMessage packets |
/// Special - used to convert GenericMessage packets |
| 246 |
/// to their appropriate Rex equivilents. |
/// to their appropriate Rex equivilents. |
| 277 |
} |
} |
| 278 |
} |
} |
| 279 |
|
|
| 280 |
|
if(method == "RexData") |
| 281 |
|
{ |
| 282 |
|
|
| 283 |
|
} |
| 284 |
|
|
| 285 |
if (method == "rexscr") |
if (method == "rexscr") |
| 286 |
{ |
{ |
| 287 |
if (OnReceiveRexClientScriptCmd != null) |
if (OnReceiveRexClientScriptCmd != null) |
| 307 |
|
|
| 308 |
} |
} |
| 309 |
|
|
| 310 |
|
public void SendRexObjectProperties(UUID id, RexObjectProperties x) |
| 311 |
|
{ |
| 312 |
|
GenericMessagePacket gmp = new GenericMessagePacket(); |
| 313 |
|
gmp.MethodData.Method = Utils.StringToBytes("RexPrimData"); |
| 314 |
|
|
| 315 |
|
byte[] temprexprimdata = x.GetRexPrimDataToBytes(); |
| 316 |
|
int numlines = 0; |
| 317 |
|
int i = 0; |
| 318 |
|
|
| 319 |
|
if (temprexprimdata != null) |
| 320 |
|
{ |
| 321 |
|
while (i <= temprexprimdata.Length) |
| 322 |
|
{ |
| 323 |
|
numlines++; |
| 324 |
|
i += 200; |
| 325 |
|
} |
| 326 |
|
} |
| 327 |
|
|
| 328 |
|
gmp.ParamList = new GenericMessagePacket.ParamListBlock[1 + numlines]; |
| 329 |
|
gmp.ParamList[0] = new GenericMessagePacket.ParamListBlock(); |
| 330 |
|
gmp.ParamList[0].Parameter = Utils.StringToBytes(id.ToString()); |
| 331 |
|
|
| 332 |
|
for (i = 0; i < numlines; i++) |
| 333 |
|
{ |
| 334 |
|
gmp.ParamList[i + 1] = new GenericMessagePacket.ParamListBlock(); |
| 335 |
|
|
| 336 |
|
if ((temprexprimdata.Length - i * 200) < 200) |
| 337 |
|
{ |
| 338 |
|
gmp.ParamList[i + 1].Parameter = new byte[temprexprimdata.Length - i * 200]; |
| 339 |
|
Buffer.BlockCopy(temprexprimdata, i * 200, gmp.ParamList[i + 1].Parameter, 0, temprexprimdata.Length - i * 200); |
| 340 |
|
} |
| 341 |
|
else |
| 342 |
|
{ |
| 343 |
|
gmp.ParamList[i + 1].Parameter = new byte[200]; |
| 344 |
|
Buffer.BlockCopy(temprexprimdata, i * 200, gmp.ParamList[i + 1].Parameter, 0, 200); |
| 345 |
|
} |
| 346 |
|
} |
| 347 |
|
|
| 348 |
|
// m_log.Warn("[REXDEBUG]: SendRexPrimData " + vPrimId.ToString()); |
| 349 |
|
OutPacket(gmp, ThrottleOutPacketType.Task); |
| 350 |
|
|
| 351 |
|
} |
| 352 |
|
|
| 353 |
/// <summary> |
/// <summary> |
| 354 |
/// Sends a Rex Script Command to the viewer |
/// Sends a Rex Script Command to the viewer |
| 355 |
/// attached to this ClientView. |
/// attached to this ClientView. |
| 424 |
{ |
{ |
| 425 |
m_log.Info("[REXCLIENT] Resolving avatar..."); |
m_log.Info("[REXCLIENT] Resolving avatar..."); |
| 426 |
Hashtable ReqVals = new Hashtable(); |
Hashtable ReqVals = new Hashtable(); |
| 427 |
ReqVals["avatar_uuid"] = AgentId.ToString(); |
ReqVals["avatar_account"] = RexAccount; |
| 428 |
ReqVals["AuthenticationAddress"] = RexAuthURL; |
ReqVals["AuthenticationAddress"] = RexAuthURL; |
| 429 |
|
|
| 430 |
ArrayList SendParams = new ArrayList(); |
ArrayList SendParams = new ArrayList(); |
| 431 |
SendParams.Add(ReqVals); |
SendParams.Add(ReqVals); |
| 432 |
|
|
| 433 |
XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", SendParams); |
XmlRpcRequest req = new XmlRpcRequest("get_user_by_account", SendParams); |
| 434 |
|
|
| 435 |
|
m_log.Info("[REXCLIENT] Sending XMLRPC Request to http://" + RexAuthURL); |
| 436 |
|
|
| 437 |
|
XmlRpcResponse authreply = req.Send("http://" + RexAuthURL, 9000); |
| 438 |
|
|
| 439 |
m_log.Info("[REXCLIENT] Sending XMLRPC Request to " + RexAuthURL); |
m_log.Info(authreply.ToString()); |
|
XmlRpcResponse authreply = req.Send(RexAuthURL, 9000); |
|
| 440 |
if (!((Hashtable)authreply.Value).ContainsKey("error_type")) |
if (!((Hashtable)authreply.Value).ContainsKey("error_type")) |
| 441 |
{ |
{ |
| 442 |
string rexAsAddress = ((Hashtable)authreply.Value)["as_address"].ToString(); |
string rexAsAddress = ((Hashtable)authreply.Value)["as_address"].ToString(); |
| 452 |
} |
} |
| 453 |
else |
else |
| 454 |
{ |
{ |
|
//Error has occurred |
|
| 455 |
m_log.Warn("[REXCLIENT]: User not found"); |
m_log.Warn("[REXCLIENT]: User not found"); |
| 456 |
} |
} |
| 457 |
} |
} |