| 13 |
using OpenSim.Framework.Communications.Cache; |
using OpenSim.Framework.Communications.Cache; |
| 14 |
using OpenSim.Region.ClientStack; |
using OpenSim.Region.ClientStack; |
| 15 |
using OpenSim.Region.ClientStack.LindenUDP; |
using OpenSim.Region.ClientStack.LindenUDP; |
| 16 |
|
using ModularRex.RexNetwork.RexLogin; |
| 17 |
|
|
| 18 |
namespace ModularRex.RexNetwork |
namespace ModularRex.RexNetwork |
| 19 |
{ |
{ |
|
public delegate void RexGenericMessageDelegate(RexClientView sender, List<string> parameters); |
|
|
public delegate void RexAppearanceDelegate(RexClientView sender); |
|
|
public delegate void RexObjectPropertiesDelegate(RexClientView sender, UUID id, RexObjectProperties props); |
|
|
public delegate void RexStartUpDelegate(RexClientView remoteClient, UUID agentID, string status); |
|
|
public delegate void RexClientScriptCmdDelegate(RexClientView remoteClient, UUID agentID, List<string> parameters); |
|
|
public delegate void ReceiveRexMediaURL(IClientAPI remoteClient, UUID agentID, UUID itemID, string mediaURL, byte refreshRate); |
|
|
|
|
| 20 |
/// <summary> |
/// <summary> |
| 21 |
/// Inherits from LLClientView the majority of functionality |
/// Inherits from LLClientView the majority of functionality |
| 22 |
/// Overrides and extends for Rex-specific functionality. |
/// Overrides and extends for Rex-specific functionality. |
| 25 |
/// between Rex and LL, you can use a override on those specific functions |
/// between Rex and LL, you can use a override on those specific functions |
| 26 |
/// to overload the request. |
/// to overload the request. |
| 27 |
/// </summary> |
/// </summary> |
| 28 |
public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance, IClientMediaURL |
public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance, IClientMediaURL, IRexClientCore |
| 29 |
{ |
{ |
| 30 |
private static readonly ILog m_log = |
private static readonly ILog m_log = |
| 31 |
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
| 34 |
|
|
| 35 |
private string m_rexAccountID; |
private string m_rexAccountID; |
| 36 |
private string m_rexAvatarURL; |
private string m_rexAvatarURL; |
| 37 |
|
private string m_rexAvatarURLOverride; |
| 38 |
private string m_rexAuthURL; |
private string m_rexAuthURL; |
| 39 |
private string m_rexSkypeURL; |
private string m_rexSkypeURL; |
|
public string AvatarStorageOverride; |
|
| 40 |
|
|
| 41 |
public float RexCharacterSpeedMod = 1.0f; |
private float m_RexCharacterSpeedMod = 1.0f; |
| 42 |
public float RexMovementSpeedMod = 1.0f; |
private float m_RexVertMovementSpeedMod = 1.0f; |
|
public float RexVertMovementSpeedMod = 1.0f; |
|
|
public bool RexWalkDisabled = false; |
|
|
public bool RexFlyDisabled = false; |
|
|
public bool RexSitDisabled = false; |
|
| 43 |
|
|
| 44 |
public event RexAppearanceDelegate OnRexAppearance; |
public event RexAppearanceDelegate OnRexAppearance; |
| 45 |
public event RexGenericMessageDelegate OnRexFaceExpression; |
public event RexGenericMessageDelegate OnRexFaceExpression; |
| 48 |
public event RexStartUpDelegate OnRexStartUp; |
public event RexStartUpDelegate OnRexStartUp; |
| 49 |
public event RexClientScriptCmdDelegate OnRexClientScriptCmd; |
public event RexClientScriptCmdDelegate OnRexClientScriptCmd; |
| 50 |
public event ReceiveRexMediaURL OnReceiveRexMediaURL; |
public event ReceiveRexMediaURL OnReceiveRexMediaURL; |
| 51 |
|
public event RexGenericMessageDelegate OnPrimFreeData; |
| 52 |
|
|
| 53 |
public RexClientView(EndPoint remoteEP, IScene scene, IAssetCache assetCache, |
public RexClientView(EndPoint remoteEP, IScene scene, IAssetCache assetCache, |
| 54 |
LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
| 86 |
AddGenericPacketHandler("RexAppearance", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexAppearance", RealXtendClientView_OnGenericMessage); |
| 87 |
AddGenericPacketHandler("RexFaceExpression", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexFaceExpression", RealXtendClientView_OnGenericMessage); |
| 88 |
AddGenericPacketHandler("RexAvatarProp", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexAvatarProp", RealXtendClientView_OnGenericMessage); |
| 89 |
|
|
| 90 |
|
//This added here only to disable warning about unhandled generic message |
| 91 |
|
//RexPrimData is actually handled in RexClientView_BinaryGenericMessage |
| 92 |
AddGenericPacketHandler("RexPrimData", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexPrimData", RealXtendClientView_OnGenericMessage); |
| 93 |
AddGenericPacketHandler("RexData", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexData", RealXtendClientView_OnGenericMessage); |
| 94 |
AddGenericPacketHandler("RexMediaUrl", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexMediaUrl", RealXtendClientView_OnGenericMessage); |
| 97 |
m_genericMessageHandlers.Add("rexfaceexpression", OnRexFaceExpression); |
m_genericMessageHandlers.Add("rexfaceexpression", OnRexFaceExpression); |
| 98 |
m_genericMessageHandlers.Add("rexavatarprop", OnRexAvatarProperties); |
m_genericMessageHandlers.Add("rexavatarprop", OnRexAvatarProperties); |
| 99 |
m_genericMessageHandlers.Add("rexmediaurl", TriggerOnReceivedRexMediaURL); |
m_genericMessageHandlers.Add("rexmediaurl", TriggerOnReceivedRexMediaURL); |
| 100 |
|
m_genericMessageHandlers.Add("rexdata", TriggerOnPrimFreeData); |
| 101 |
} |
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
/// <summary> |
/// <summary> |
| 106 |
/// Registers interfaces for IClientCore, |
/// Registers interfaces for IClientCore, |
| 107 |
/// every time you make a new Rex-specific |
/// every time you make a new Rex-specific |
| 111 |
{ |
{ |
| 112 |
RegisterInterface<IClientRexAppearance>(this); |
RegisterInterface<IClientRexAppearance>(this); |
| 113 |
RegisterInterface<IClientRexFaceExpression>(this); |
RegisterInterface<IClientRexFaceExpression>(this); |
| 114 |
|
RegisterInterface<IClientMediaURL>(this); |
| 115 |
|
RegisterInterface<IRexClientCore>(this); |
| 116 |
|
|
| 117 |
// Register our own class 'as-is' so it can be |
// Register our own class 'as-is' so it can be |
| 118 |
// used via IClientCore.Get<RexClientView>()... |
// used via IClientCore.Get<RexClientView>()... |
| 121 |
base.RegisterInterfaces(); |
base.RegisterInterfaces(); |
| 122 |
} |
} |
| 123 |
|
|
| 124 |
|
#region Properties |
| 125 |
|
|
| 126 |
/// <summary> |
/// <summary> |
| 127 |
/// The avatar URL for this avatar |
/// The avatar URL for this avatar |
| 128 |
/// Eg: http://avatar.com:10000/uuid/ |
/// Eg: http://avatar.com:10000/uuid/ |
| 142 |
} |
} |
| 143 |
|
|
| 144 |
/// <summary> |
/// <summary> |
| 145 |
|
/// The avatar URL override for this avatar |
| 146 |
|
/// Eg: http://avatar.com:10000/uuid/ |
| 147 |
|
/// </summary> |
| 148 |
|
public string RexAvatarURLOverride |
| 149 |
|
{ |
| 150 |
|
get { return m_rexAvatarURLOverride; } |
| 151 |
|
set |
| 152 |
|
{ |
| 153 |
|
m_rexAvatarURLOverride = value; |
| 154 |
|
if (OnRexAppearance != null) |
| 155 |
|
{ |
| 156 |
|
OnRexAppearance(this); |
| 157 |
|
return; |
| 158 |
|
} |
| 159 |
|
} |
| 160 |
|
} |
| 161 |
|
|
| 162 |
|
/// <summary> |
| 163 |
|
/// The URL to avatar appearance which this view currently uses. |
| 164 |
|
/// If override is used, return it. Otherwise return normal avatar url. |
| 165 |
|
/// Eg: http://avatar.com:10000/uuid/ |
| 166 |
|
/// </summary> |
| 167 |
|
public string RexAvatarURLVisible |
| 168 |
|
{ |
| 169 |
|
get |
| 170 |
|
{ |
| 171 |
|
if (!string.IsNullOrEmpty(RexAvatarURLOverride)) |
| 172 |
|
return RexAvatarURLOverride; |
| 173 |
|
else |
| 174 |
|
return RexAvatarURL; |
| 175 |
|
} |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
|
| 179 |
|
/// <summary> |
| 180 |
/// Skype username of the avatar |
/// Skype username of the avatar |
| 181 |
/// eg: Skypeuser |
/// eg: Skypeuser |
| 182 |
/// </summary> |
/// </summary> |
| 227 |
} |
} |
| 228 |
} |
} |
| 229 |
|
|
| 230 |
|
public float RexCharacterSpeedMod |
| 231 |
|
{ |
| 232 |
|
get { return m_RexCharacterSpeedMod; } |
| 233 |
|
set { m_RexCharacterSpeedMod = value; } |
| 234 |
|
} |
| 235 |
|
|
| 236 |
|
public float RexVertMovementSpeedMod |
| 237 |
|
{ |
| 238 |
|
get { return m_RexVertMovementSpeedMod; } |
| 239 |
|
set { m_RexVertMovementSpeedMod = value; } |
| 240 |
|
} |
| 241 |
|
|
| 242 |
|
#endregion |
| 243 |
|
|
| 244 |
|
|
| 245 |
private void RexClientView_BinaryGenericMessage(Object sender, string method, byte[][] args) |
private void RexClientView_BinaryGenericMessage(Object sender, string method, byte[][] args) |
| 246 |
{ |
{ |
| 247 |
if(method == "RexPrimData".ToLower()) |
if(method == "RexPrimData".ToLower()) |
| 309 |
return; |
return; |
| 310 |
} |
} |
| 311 |
|
|
| 312 |
if (method == "RexAppearance") |
if (method.ToLower() == "rexappearance") |
| 313 |
{ |
{ |
| 314 |
if (OnRexAppearance != null) |
if (OnRexAppearance != null) |
| 315 |
{ |
{ |
| 335 |
return; |
return; |
| 336 |
} |
} |
| 337 |
} |
} |
| 338 |
|
if (method == "rexprimdata") |
| 339 |
|
return; |
| 340 |
|
|
| 341 |
m_log.Warn("[REXCLIENT] Unhandled GenericMessage (" + method + ") {"); |
m_log.Warn("[REXCLIENT] Unhandled GenericMessage (" + method + ") {"); |
| 342 |
foreach (string s in args) |
foreach (string s in args) |
| 346 |
m_log.Warn("}"); |
m_log.Warn("}"); |
| 347 |
} |
} |
| 348 |
|
|
| 349 |
|
private void TriggerOnPrimFreeData(IClientAPI sender, List<string> args) |
| 350 |
|
{ |
| 351 |
|
try |
| 352 |
|
{ |
| 353 |
|
//foreach (string s in args) |
| 354 |
|
//{ |
| 355 |
|
// m_log.Debug("[REXCLIENT] PrimFreeData: " + s); |
| 356 |
|
//} |
| 357 |
|
|
| 358 |
|
if (OnPrimFreeData != null) |
| 359 |
|
{ |
| 360 |
|
OnPrimFreeData(this, args); |
| 361 |
|
} |
| 362 |
|
} |
| 363 |
|
catch (Exception e) |
| 364 |
|
{ |
| 365 |
|
m_log.ErrorFormat("[REXCLIENT] Error parseing incoming prim free data. Exception: ", e); |
| 366 |
|
} |
| 367 |
|
} |
| 368 |
|
|
| 369 |
private void TriggerOnReceivedRexMediaURL(IClientAPI sender, List<string> args) |
private void TriggerOnReceivedRexMediaURL(IClientAPI sender, List<string> args) |
| 370 |
{ |
{ |
| 371 |
try |
try |
| 687 |
{ |
{ |
| 688 |
List<string> pack = new List<string>(); |
List<string> pack = new List<string>(); |
| 689 |
|
|
| 690 |
pack.Add(direction.ToString()); |
string slightDirection = direction.X.ToString() + " " + direction.Y.ToString() + " " + direction.Z.ToString(); |
| 691 |
pack.Add(colour.ToString()); |
slightDirection = slightDirection.Replace(",", "."); |
| 692 |
pack.Add(ambientColour.ToString()); |
string slightColour = colour.X.ToString() + " " + colour.Y.ToString() + " " + colour.Z.ToString(); |
| 693 |
|
slightColour = slightColour.Replace(",", "."); |
| 694 |
|
string sambientColour = ambientColour.X.ToString() + " " + ambientColour.Y.ToString() + " " + ambientColour.Z.ToString(); |
| 695 |
|
sambientColour = sambientColour.Replace(",", "."); |
| 696 |
|
|
| 697 |
|
pack.Add(slightDirection); |
| 698 |
|
pack.Add(slightColour); |
| 699 |
|
pack.Add(sambientColour); |
| 700 |
|
|
| 701 |
SendGenericMessage("RexAmbientL", pack); |
SendGenericMessage("RexAmbientL", pack); |
| 702 |
} |
} |
| 954 |
|
|
| 955 |
public override void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) |
public override void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) |
| 956 |
{ |
{ |
| 957 |
m_log.Debug("[REXCLIENT]: Informing Client About Neighbour"); |
IRexUDPPort module = m_scene.RequestModuleInterface<IRexUDPPort>(); |
| 958 |
neighbourExternalEndPoint.Port = neighbourExternalEndPoint.Port - 2000; |
int udpport = module.GetPort(neighbourHandle); |
| 959 |
base.InformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint); |
|
| 960 |
|
m_log.DebugFormat("[REXCLIENT]: Informing Client About Neighbour {0}", neighbourExternalEndPoint); |
| 961 |
|
base.InformClientOfNeighbour(neighbourHandle, new IPEndPoint(neighbourExternalEndPoint.Address, udpport)); |
| 962 |
} |
} |
| 963 |
|
|
| 964 |
public override void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint, |
public override void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint, |
| 965 |
string capsURL) |
string capsURL) |
| 966 |
{ |
{ |
| 967 |
m_log.Debug("[REXCLIENT]: Crossing client to region"); |
IRexUDPPort module = m_scene.RequestModuleInterface<IRexUDPPort>(); |
| 968 |
externalIPEndPoint.Port = externalIPEndPoint.Port - 2000; |
int udpport = module.GetPort(newRegionHandle); |
| 969 |
base.CrossRegion(newRegionHandle, pos, lookAt, externalIPEndPoint, capsURL); |
|
| 970 |
|
m_log.DebugFormat("[REXCLIENT]: Crossing client to region {0}", externalIPEndPoint); |
| 971 |
|
base.CrossRegion(newRegionHandle, pos, lookAt, new IPEndPoint(externalIPEndPoint.Address, udpport), capsURL); |
| 972 |
} |
} |
| 973 |
|
|
| 974 |
public override void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, |
public override void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, |
| 975 |
uint flags, string capsURL) |
uint flags, string capsURL) |
| 976 |
{ |
{ |
| 977 |
m_log.Debug("[REXCLIENT]: Sending region teleport to client"); |
IRexUDPPort module = m_scene.RequestModuleInterface<IRexUDPPort>(); |
| 978 |
newRegionEndPoint.Port = newRegionEndPoint.Port - 2000; |
int udpport = module.GetPort(regionHandle); |
| 979 |
base.SendRegionTeleport(regionHandle, simAccess, newRegionEndPoint, locationID, flags, capsURL); |
|
| 980 |
|
m_log.DebugFormat("[REXCLIENT]: Sending region teleport to client {0}", newRegionEndPoint); |
| 981 |
|
base.SendRegionTeleport(regionHandle, simAccess, new IPEndPoint(newRegionEndPoint.Address, udpport), locationID, flags, capsURL); |
| 982 |
} |
} |
| 983 |
} |
} |
| 984 |
} |
} |