| 16 |
|
|
| 17 |
namespace ModularRex.RexNetwork |
namespace ModularRex.RexNetwork |
| 18 |
{ |
{ |
| 19 |
|
public delegate void RexGenericMessageDelegate(RexClientView sender, List<string> parameters); |
| 20 |
public delegate void RexAppearanceDelegate(RexClientView sender); |
public delegate void RexAppearanceDelegate(RexClientView sender); |
|
public delegate void RexFaceExpressionDelegate(RexClientView sender, List<string> parameters); |
|
|
public delegate void RexAvatarPropertiesDelegate(RexClientView sender, List<string> parameters); |
|
| 21 |
public delegate void RexObjectPropertiesDelegate(RexClientView sender, UUID id, RexObjectProperties props); |
public delegate void RexObjectPropertiesDelegate(RexClientView sender, UUID id, RexObjectProperties props); |
| 22 |
public delegate void RexStartUpDelegate(RexClientView remoteClient, UUID agentID, string status); |
public delegate void RexStartUpDelegate(RexClientView remoteClient, UUID agentID, string status); |
| 23 |
public delegate void RexClientScriptCmdDelegate(RexClientView remoteClient, UUID agentID, List<string> parameters); |
public delegate void RexClientScriptCmdDelegate(RexClientView remoteClient, UUID agentID, List<string> parameters); |
| 24 |
|
public delegate void ReceiveRexMediaURL(IClientAPI remoteClient, UUID agentID, UUID itemID, string mediaURL, byte refreshRate); |
| 25 |
|
|
| 26 |
/// <summary> |
/// <summary> |
| 27 |
/// Inherits from LLClientView the majority of functionality |
/// Inherits from LLClientView the majority of functionality |
| 31 |
/// 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 |
| 32 |
/// to overload the request. |
/// to overload the request. |
| 33 |
/// </summary> |
/// </summary> |
| 34 |
public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance |
public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance, IClientMediaURL |
| 35 |
{ |
{ |
| 36 |
private static readonly ILog m_log = |
private static readonly ILog m_log = |
| 37 |
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
| 38 |
|
|
| 39 |
|
protected Dictionary<string, RexGenericMessageDelegate> m_genericMessageHandlers = new Dictionary<string, RexGenericMessageDelegate>(); |
| 40 |
|
|
| 41 |
private string m_rexAccountID; |
private string m_rexAccountID; |
| 42 |
private string m_rexAvatarURL; |
private string m_rexAvatarURL; |
| 43 |
private string m_rexAuthURL; |
private string m_rexAuthURL; |
| 52 |
public bool RexSitDisabled = false; |
public bool RexSitDisabled = false; |
| 53 |
|
|
| 54 |
public event RexAppearanceDelegate OnRexAppearance; |
public event RexAppearanceDelegate OnRexAppearance; |
| 55 |
public event RexFaceExpressionDelegate OnRexFaceExpression; |
public event RexGenericMessageDelegate OnRexFaceExpression; |
| 56 |
public event RexAvatarPropertiesDelegate OnRexAvatarProperties; |
public event RexGenericMessageDelegate OnRexAvatarProperties; |
| 57 |
public event RexObjectPropertiesDelegate OnRexObjectProperties; |
public event RexObjectPropertiesDelegate OnRexObjectProperties; |
| 58 |
public event RexStartUpDelegate OnRexStartUp; |
public event RexStartUpDelegate OnRexStartUp; |
| 59 |
public event RexClientScriptCmdDelegate OnRexClientScriptCmd; |
public event RexClientScriptCmdDelegate OnRexClientScriptCmd; |
| 60 |
|
public event ReceiveRexMediaURL OnReceiveRexMediaURL; |
| 61 |
|
|
| 62 |
public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, |
public RexClientView(EndPoint remoteEP, IScene scene, IAssetCache assetCache, |
| 63 |
LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
| 64 |
UUID sessionId, uint circuitCode, EndPoint proxyEP, ClientStackUserSettings userSettings) |
UUID sessionId, uint circuitCode, EndPoint proxyEP, ClientStackUserSettings userSettings) |
| 65 |
: base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
: base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 67 |
{ |
{ |
| 68 |
// Rex communication now occurs via GenericMessage |
// Rex communication now occurs via GenericMessage |
| 69 |
// We have a special handler here below. |
// We have a special handler here below. |
| 70 |
AddGenericPacketHandler("RexAppearance", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandlers(); |
|
AddGenericPacketHandler("RexFaceExpression", RealXtendClientView_OnGenericMessage); |
|
|
AddGenericPacketHandler("RexAvatarProp", RealXtendClientView_OnGenericMessage); |
|
|
AddGenericPacketHandler("RexPrimData", RealXtendClientView_OnGenericMessage); |
|
|
AddGenericPacketHandler("RexData", RealXtendClientView_OnGenericMessage); |
|
| 71 |
|
|
| 72 |
OnBinaryGenericMessage += RexClientView_BinaryGenericMessage; |
OnBinaryGenericMessage += RexClientView_BinaryGenericMessage; |
| 73 |
OnGenericMessage += RealXtendClientView_OnGenericMessage; |
OnGenericMessage += RealXtendClientView_OnGenericMessage; |
| 82 |
// Rex communication now occurs via GenericMessage |
// Rex communication now occurs via GenericMessage |
| 83 |
// We need to register GenericMessage handlers |
// We need to register GenericMessage handlers |
| 84 |
|
|
| 85 |
|
AddGenericPacketHandlers(); |
| 86 |
|
|
| 87 |
|
OnBinaryGenericMessage += RexClientView_BinaryGenericMessage; |
| 88 |
|
|
| 89 |
|
RexAvatarURL = rexAvatarURL; |
| 90 |
|
RexAuthURL = rexAuthURL; |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
private void AddGenericPacketHandlers() |
| 94 |
|
{ |
| 95 |
AddGenericPacketHandler("RexAppearance", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexAppearance", RealXtendClientView_OnGenericMessage); |
| 96 |
AddGenericPacketHandler("RexFaceExpression", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexFaceExpression", RealXtendClientView_OnGenericMessage); |
| 97 |
AddGenericPacketHandler("RexAvatarProp", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexAvatarProp", RealXtendClientView_OnGenericMessage); |
| 98 |
AddGenericPacketHandler("RexPrimData", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexPrimData", RealXtendClientView_OnGenericMessage); |
| 99 |
AddGenericPacketHandler("RexData", RealXtendClientView_OnGenericMessage); |
AddGenericPacketHandler("RexData", RealXtendClientView_OnGenericMessage); |
| 100 |
|
AddGenericPacketHandler("RexMediaUrl", RealXtendClientView_OnGenericMessage); |
| 101 |
|
AddGenericPacketHandler("rexstartup", RealXtendClientView_OnGenericMessage); |
| 102 |
|
|
| 103 |
OnBinaryGenericMessage += RexClientView_BinaryGenericMessage; |
m_genericMessageHandlers.Add("rexfaceexpression", OnRexFaceExpression); |
| 104 |
|
m_genericMessageHandlers.Add("rexavatarprop", OnRexAvatarProperties); |
| 105 |
RexAvatarURL = rexAvatarURL; |
m_genericMessageHandlers.Add("rexmediaurl", TriggerOnReceivedRexMediaURL); |
|
RexAuthURL = rexAuthURL; |
|
| 106 |
} |
} |
| 107 |
|
|
| 108 |
/// <summary> |
/// <summary> |
| 191 |
} |
} |
| 192 |
} |
} |
| 193 |
|
|
| 194 |
void RexClientView_BinaryGenericMessage(Object sender, string method, byte[][] args) |
private void RexClientView_BinaryGenericMessage(Object sender, string method, byte[][] args) |
| 195 |
{ |
{ |
| 196 |
if(method == "RexPrimData".ToLower()) |
if(method == "RexPrimData".ToLower()) |
| 197 |
{ |
{ |
| 245 |
/// Eg: GenericMessage(RexAppearance) -> |
/// Eg: GenericMessage(RexAppearance) -> |
| 246 |
/// OnRexAppearance(...) |
/// OnRexAppearance(...) |
| 247 |
/// </summary> |
/// </summary> |
| 248 |
void RealXtendClientView_OnGenericMessage(object sender, string method, List<string> args) |
private void RealXtendClientView_OnGenericMessage(object sender, string method, List<string> args) |
| 249 |
{ |
{ |
| 250 |
//TODO: Convert to Dictionary<Method, GenericMessageHandler> |
RexGenericMessageDelegate handler; |
| 251 |
if (method == "RexAppearance") |
if (m_genericMessageHandlers.ContainsKey(method.ToLower())) |
|
if (OnRexAppearance != null) |
|
| 252 |
{ |
{ |
| 253 |
OnRexAppearance(this); |
handler = m_genericMessageHandlers[method.ToLower()]; |
| 254 |
return; |
if (handler != null) |
|
} |
|
|
|
|
|
if (method == "RexFaceExpression") |
|
|
{ |
|
|
if (OnRexFaceExpression != null) |
|
| 255 |
{ |
{ |
| 256 |
OnRexFaceExpression(this, args); |
handler(this, args); |
|
return; |
|
| 257 |
} |
} |
| 258 |
|
return; |
| 259 |
} |
} |
| 260 |
|
|
| 261 |
if (method == "RexAvatarProp") |
if (method == "RexAppearance") |
| 262 |
{ |
{ |
| 263 |
if(OnRexAvatarProperties != null) |
if (OnRexAppearance != null) |
| 264 |
{ |
{ |
| 265 |
OnRexAvatarProperties(this, args); |
OnRexAppearance(this); |
| 266 |
return; |
return; |
| 267 |
} |
} |
| 268 |
} |
} |
| 269 |
|
|
|
if(method == "RexData") |
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
| 270 |
if (method == "rexscr") |
if (method == "rexscr") |
| 271 |
{ |
{ |
| 272 |
if (OnRexClientScriptCmd != null) |
if (OnRexClientScriptCmd != null) |
| 276 |
} |
} |
| 277 |
} |
} |
| 278 |
|
|
| 279 |
if (method == "RexStartup") |
if (method == "rexstartup") |
| 280 |
{ |
{ |
| 281 |
if (OnRexStartUp != null) |
if (OnRexStartUp != null) |
| 282 |
{ |
{ |
| 285 |
} |
} |
| 286 |
} |
} |
| 287 |
|
|
| 288 |
m_log.Warn("[REXCLIENTVIEW] Unhandled GenericMessage (" + method + ") {"); |
m_log.Warn("[REXCLIENT] Unhandled GenericMessage (" + method + ") {"); |
| 289 |
foreach (string s in args) |
foreach (string s in args) |
| 290 |
{ |
{ |
| 291 |
m_log.Warn("\t" + s); |
m_log.Warn("\t" + s); |
| 293 |
m_log.Warn("}"); |
m_log.Warn("}"); |
| 294 |
} |
} |
| 295 |
|
|
| 296 |
|
private void TriggerOnReceivedRexMediaURL(IClientAPI sender, List<string> args) |
| 297 |
|
{ |
| 298 |
|
try |
| 299 |
|
{ |
| 300 |
|
foreach (string s in args) |
| 301 |
|
{ |
| 302 |
|
m_log.Debug("[REXCLIENT] MediaURL: " + s); |
| 303 |
|
} |
| 304 |
|
|
| 305 |
|
UUID assetID = new UUID(args[0]); |
| 306 |
|
string mediaUrl = args[1]; |
| 307 |
|
byte refreshRate = Convert.ToByte(args[2]); |
| 308 |
|
|
| 309 |
|
if (OnReceiveRexMediaURL != null) |
| 310 |
|
{ |
| 311 |
|
OnReceiveRexMediaURL(this, AgentId, assetID, mediaUrl, refreshRate); |
| 312 |
|
} |
| 313 |
|
} |
| 314 |
|
catch (Exception e) |
| 315 |
|
{ |
| 316 |
|
m_log.ErrorFormat("[REXCLIENT] Error parseing incoming media url. Exception: ", e); |
| 317 |
|
} |
| 318 |
|
} |
| 319 |
|
|
| 320 |
public void SendRexObjectProperties(UUID id, RexObjectProperties x) |
public void SendRexObjectProperties(UUID id, RexObjectProperties x) |
| 321 |
{ |
{ |
| 322 |
GenericMessagePacket gmp = new GenericMessagePacket(); |
GenericMessagePacket gmp = new GenericMessagePacket(); |
| 528 |
/// <param name="height">Height of the texture</param> |
/// <param name="height">Height of the texture</param> |
| 529 |
public void SendRexRttCamera(int command, string name, UUID assetId, Vector3 pos, Vector3 lookat, int width, int height) |
public void SendRexRttCamera(int command, string name, UUID assetId, Vector3 pos, Vector3 lookat, int width, int height) |
| 530 |
{ |
{ |
| 531 |
|
string sPos = pos.X.ToString() + " " + pos.Y.ToString() + " " + pos.Z.ToString(); |
| 532 |
|
sPos = sPos.Replace(",", "."); |
| 533 |
|
string sLookAt = lookat.X.ToString() + " " + lookat.Y.ToString() + " " + lookat.Z.ToString(); |
| 534 |
|
sLookAt = sLookAt.Replace(",", "."); |
| 535 |
|
|
| 536 |
List<string> pack = new List<string>(); |
List<string> pack = new List<string>(); |
| 537 |
|
|
| 538 |
pack.Add(command.ToString()); |
pack.Add(command.ToString()); |
| 539 |
pack.Add(name); |
pack.Add(name); |
| 540 |
pack.Add(assetId.ToString()); |
pack.Add(assetId.ToString()); |
| 541 |
pack.Add(pos.ToString()); |
pack.Add(sPos); |
| 542 |
pack.Add(lookat.ToString()); |
pack.Add(sLookAt); |
| 543 |
pack.Add(width.ToString()); |
pack.Add(width.ToString()); |
| 544 |
pack.Add(height.ToString()); |
pack.Add(height.ToString()); |
| 545 |
|
|
| 644 |
SendGenericMessage("RexFlashAnim", pack); |
SendGenericMessage("RexFlashAnim", pack); |
| 645 |
} |
} |
| 646 |
|
|
| 647 |
internal void SendRexPreloadAvatarAssets(List<string> vAssetsList) |
/// <summary> |
| 648 |
|
/// Sends preload avatar assets |
| 649 |
|
/// </summary> |
| 650 |
|
/// <param name="assetList">List of avatar assets</param> |
| 651 |
|
public void SendRexPreloadAvatarAssets(List<string> assetList) |
| 652 |
|
{ |
| 653 |
|
try |
| 654 |
|
{ |
| 655 |
|
List<string> pack = new List<string>(); |
| 656 |
|
|
| 657 |
|
foreach (string avatarUrl in assetList) |
| 658 |
{ |
{ |
| 659 |
throw new System.NotImplementedException(); |
pack.Add(avatarUrl); |
| 660 |
|
} |
| 661 |
|
|
| 662 |
|
SendGenericMessage("RexPreloadAppearance", pack); |
| 663 |
|
} |
| 664 |
|
catch (Exception exep) |
| 665 |
|
{ |
| 666 |
|
m_log.Error("[REXCLIENT]: SendRexPreloadAvatarAssets fail:" + exep.ToString()); |
| 667 |
|
} |
| 668 |
} |
} |
| 669 |
|
|
| 670 |
/// <summary> |
/// <summary> |
| 722 |
SendGenericMessage("RexSky", pack); |
SendGenericMessage("RexSky", pack); |
| 723 |
} |
} |
| 724 |
|
|
| 725 |
internal void SendRexPreloadAssets(Dictionary<UUID, uint> tempassetlist) |
/// <summary> |
| 726 |
|
/// Sends list of preloaded assets to user |
| 727 |
|
/// </summary> |
| 728 |
|
/// <param name="assetList"></param> |
| 729 |
|
public void SendRexPreloadAssets(Dictionary<UUID, uint> assetList) |
| 730 |
|
{ |
| 731 |
|
try |
| 732 |
|
{ |
| 733 |
|
List<string> pack = new List<string>(); |
| 734 |
|
|
| 735 |
|
string assetline = String.Empty; |
| 736 |
|
foreach (UUID materialUUID in assetList.Keys) |
| 737 |
|
{ |
| 738 |
|
assetline = assetList[materialUUID] + " " + materialUUID.ToString(); |
| 739 |
|
pack.Add(assetline); |
| 740 |
|
} |
| 741 |
|
|
| 742 |
|
SendGenericMessage("RexPreloadAssets", pack); |
| 743 |
|
} |
| 744 |
|
catch (Exception exep) |
| 745 |
{ |
{ |
| 746 |
throw new System.NotImplementedException(); |
m_log.Error("[REXCLIENT]: SendRexPreloadAssets fail:" + exep.ToString()); |
| 747 |
|
} |
| 748 |
} |
} |
| 749 |
|
|
| 750 |
/// <summary> |
/// <summary> |
| 755 |
/// <param name="refreshRate">How many times per second to refresh the texture</param> |
/// <param name="refreshRate">How many times per second to refresh the texture</param> |
| 756 |
public void SendMediaURL(UUID assetId, string mediaURL, byte refreshRate) |
public void SendMediaURL(UUID assetId, string mediaURL, byte refreshRate) |
| 757 |
{ |
{ |
| 758 |
|
if (mediaURL == null) |
| 759 |
|
{ |
| 760 |
|
m_log.Warn("[REXCLIENT]: Did not send media url to user, because it was null"); |
| 761 |
|
return; |
| 762 |
|
} |
| 763 |
List<string> pack = new List<string>(); |
List<string> pack = new List<string>(); |
| 764 |
|
|
| 765 |
pack.Add(assetId.ToString()); |
pack.Add(assetId.ToString()); |
| 818 |
SendGenericMessage("RexMorph", pack); |
SendGenericMessage("RexMorph", pack); |
| 819 |
} |
} |
| 820 |
|
|
| 821 |
internal void SendRexMeshAnimation(UUID uUID, string vAnimName, float vRate, bool vbLooped, bool vbStopAnim) |
/// <summary> |
| 822 |
|
/// Send Mesh Animation command to client |
| 823 |
|
/// </summary> |
| 824 |
|
/// <param name="primId">id of the primitive</param> |
| 825 |
|
/// <param name="animationName">Name of the animation to launch</param> |
| 826 |
|
/// <param name="rate">Speed of the animation, where 1.0 is default speed</param> |
| 827 |
|
/// <param name="loop">True to make the animation looped, false to play it only once</param> |
| 828 |
|
/// <param name="stopAnimation">True to stop the animation, false to launch the animation</param> |
| 829 |
|
public void SendRexMeshAnimation(UUID primId, string animationName, float rate, bool loop, bool stopAnimation) |
| 830 |
{ |
{ |
| 831 |
throw new System.NotImplementedException(); |
List<string> pack = new List<string>(); |
| 832 |
|
|
| 833 |
|
pack.Add(primId.ToString()); |
| 834 |
|
pack.Add(animationName); |
| 835 |
|
pack.Add(rate.ToString()); |
| 836 |
|
pack.Add(loop.ToString()); |
| 837 |
|
pack.Add(stopAnimation.ToString()); |
| 838 |
|
|
| 839 |
|
SendGenericMessage("RexPrimAnim", pack); |
| 840 |
} |
} |
| 841 |
|
|
| 842 |
internal void SendRexClientSideEffect(string assetId, float vTimeUntilLaunch, float vTimeUntilDeath, Vector3 pos, Quaternion rot, float vSpeed) |
/// <summary> |
| 843 |
|
/// Send Client side effect to client |
| 844 |
|
/// </summary> |
| 845 |
|
/// <param name="assetId">Id of the asset</param> |
| 846 |
|
/// <param name="timeUntilLaunch">Time in seconds until the effect is launched on the client. |
| 847 |
|
/// Set to zero to launch immediatelly</param> |
| 848 |
|
/// <param name="timeUntilDeath">The duration of the effect. The particle system gets completely |
| 849 |
|
/// destroyed after this duration. The duration is counted after the effect is launched. </param> |
| 850 |
|
/// <param name="pos">Position of the effect in the world</param> |
| 851 |
|
/// <param name="rot">Rotation of the particle system. Affects it's movement if speed > 0</param> |
| 852 |
|
/// <param name="speed">Speed at which the particle system moves. The system moves at the direction |
| 853 |
|
/// specified by rot. Set to zero to make it stationary.</param> |
| 854 |
|
public void SendRexClientSideEffect(string assetId, float timeUntilLaunch, float timeUntilDeath, Vector3 pos, Quaternion rot, float speed) |
| 855 |
{ |
{ |
| 856 |
throw new System.NotImplementedException(); |
List<string> pack = new List<string>(); |
| 857 |
|
|
| 858 |
|
pack.Add(assetId.ToString()); |
| 859 |
|
pack.Add(timeUntilLaunch.ToString().Replace(",", ".")); |
| 860 |
|
pack.Add(timeUntilDeath.ToString().Replace(",", ".")); |
| 861 |
|
|
| 862 |
|
string sPos = pos.X.ToString() + " " + pos.Y.ToString() + " " + pos.Z.ToString(); |
| 863 |
|
sPos = sPos.Replace(",", "."); |
| 864 |
|
pack.Add(sPos); |
| 865 |
|
|
| 866 |
|
string sRot = rot.X.ToString() + " " + rot.Y.ToString() + " " + rot.Z.ToString() + " " + rot.W.ToString(); |
| 867 |
|
sRot = sRot.Replace(",", "."); |
| 868 |
|
pack.Add(sRot); |
| 869 |
|
|
| 870 |
|
pack.Add(speed.ToString().Replace(",", ".")); |
| 871 |
|
|
| 872 |
|
SendGenericMessage("RexCSEffect", pack); |
| 873 |
} |
} |
| 874 |
|
|
| 875 |
|
//public override void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) |
| 876 |
|
//{ |
| 877 |
|
// m_log.Debug("[REXCLIENT]: Informing Client About Neighbour"); |
| 878 |
|
// neighbourExternalEndPoint.Port = neighbourExternalEndPoint.Port - 2000; |
| 879 |
|
// base.InformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint); |
| 880 |
|
//} |
| 881 |
} |
} |
| 882 |
} |
} |