| 1 |
using System.Collections.Generic; |
using System; |
| 2 |
|
using System.Collections; |
| 3 |
|
using System.Collections.Generic; |
| 4 |
using System.Reflection; |
using System.Reflection; |
| 5 |
|
using System.Timers; |
| 6 |
using log4net; |
using log4net; |
| 7 |
using ModularRex.RexNetwork; |
using ModularRex.RexNetwork; |
| 8 |
using Nini.Config; |
using Nini.Config; |
| 9 |
|
using Nwc.XmlRpc; |
| 10 |
using OpenMetaverse; |
using OpenMetaverse; |
|
using OpenMetaverse.Packets; |
|
| 11 |
using OpenSim.Framework; |
using OpenSim.Framework; |
| 12 |
using OpenSim.Region.Environment.Interfaces; |
using OpenSim.Region.Environment.Interfaces; |
| 13 |
using OpenSim.Region.Environment.Scenes; |
using OpenSim.Region.Environment.Scenes; |
| 19 |
private static readonly ILog m_log = |
private static readonly ILog m_log = |
| 20 |
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
| 21 |
|
|
| 22 |
// This is the 'cheapest' time-wise conversion of the Rex code to a module. |
private string m_rexAuthServer = "http://127.0.0.1:8002"; |
| 23 |
// It's also the most likely to break horribly once OutPacket is depreciated |
private Queue<XmlRpcRequest> m_reqAuthQueue = new Queue<XmlRpcRequest>(); |
| 24 |
public void SendRexAppearanceAlpha(IClientAPI user, UUID agentID, string avatarAddress) //rex |
private Timer m_reqAuthTimer = new Timer(1500); |
|
{ |
|
|
GenericMessagePacket gmp = new GenericMessagePacket(); |
|
|
gmp.MethodData.Method = Utils.StringToBytes("RexAppearance"); |
|
|
gmp.ParamList = new GenericMessagePacket.ParamListBlock[2]; |
|
|
gmp.ParamList[0] = new GenericMessagePacket.ParamListBlock(); |
|
|
gmp.ParamList[0].Parameter = Utils.StringToBytes(avatarAddress); |
|
|
gmp.ParamList[1] = new GenericMessagePacket.ParamListBlock(); |
|
|
gmp.ParamList[1].Parameter = Utils.StringToBytes(agentID.ToString()); |
|
|
|
|
|
user.OutPacket(gmp, ThrottleOutPacketType.Task); |
|
|
} |
|
|
|
|
|
// We converted the Send/Recieve GenericMessage into an IClientAPI function and event |
|
|
// these are OnGenericMessage and SendGenericMessage, however this is still |
|
|
// not ideal since we're doing "Packet Logic" in a Region Module. |
|
|
public void SendRexAppearanceBeta(IClientAPI user, UUID agentID, string avatarAddress) |
|
|
{ |
|
|
List<string> pack = new List<string>(); |
|
|
pack.Add(avatarAddress); |
|
|
pack.Add(agentID.ToString()); |
|
|
|
|
|
user.SendGenericMessage("RexAppearance", pack); |
|
|
} |
|
|
|
|
|
// Final conversion: |
|
|
// RealXtendClientView derives from LLClientView |
|
|
// Implements additional SendXYZ/etc functions, and converts them |
|
|
// to genericmessage handlers, etc. |
|
|
// |
|
|
// This requires a 'smart' incoming ClientStack listener which will substantiate |
|
|
// a RealXtendClientView instead of LLClientView when the Rex version string has |
|
|
// been encountered. |
|
|
// |
|
|
// Upsides: Very clean, allows overriding of other methods and functionality |
|
|
// when required. |
|
|
// We dont send Rex packets to clients which dont support them |
|
|
// (big plus for the older packets which crash the viewer) |
|
|
// |
|
|
// Downsides: Using the Rex protocol in conjunction with another version string |
|
|
// wont work. This is fixable in time by converting checks from |
|
|
// RealXtendClientView to IRexClientView (that particular mod is |
|
|
// relatively painless) |
|
| 25 |
|
|
| 26 |
public void SendRexAppearanceGamma(IClientAPI user, UUID agentID, string avatarAddress) |
private List<Scene> m_scenes = new List<Scene>(); |
| 27 |
|
|
| 28 |
|
public void RequestRexAuthentication(UUID avatarID, string authAddress) |
| 29 |
{ |
{ |
| 30 |
if(user is RexClientView) |
Hashtable ReqVals = new Hashtable(); |
| 31 |
|
ReqVals["avatar_uuid"] = avatarID.ToString(); |
| 32 |
|
ReqVals["AuthenticationAddress"] = authAddress; |
| 33 |
|
|
| 34 |
|
ArrayList SendParams = new ArrayList(); |
| 35 |
|
SendParams.Add(ReqVals); |
| 36 |
|
|
| 37 |
|
XmlRpcRequest RexReq = new XmlRpcRequest("get_user_by_uuid", SendParams); |
| 38 |
|
|
| 39 |
|
lock(m_reqAuthQueue) |
| 40 |
{ |
{ |
| 41 |
RexClientView rex = (RexClientView) user; |
m_reqAuthQueue.Enqueue(RexReq); |
|
rex.SendRexAppearance(agentID, avatarAddress); |
|
| 42 |
} |
} |
| 43 |
|
|
| 44 |
|
m_reqAuthTimer.AutoReset = false; |
| 45 |
|
m_reqAuthTimer.Stop(); |
| 46 |
|
m_reqAuthTimer.Start(); |
| 47 |
} |
} |
| 48 |
|
|
| 49 |
|
public void SendAppearanceToAllUsers(UUID user, string avatarServerURL) |
| 50 |
|
{ |
| 51 |
|
foreach (Scene scene in m_scenes) |
| 52 |
|
{ |
| 53 |
|
scene.ForEachScenePresence( |
| 54 |
|
delegate(ScenePresence avatar) |
| 55 |
|
{ |
| 56 |
|
if (avatar.ControllingClient is RexClientView) |
| 57 |
|
{ |
| 58 |
|
((RexClientView) avatar.ControllingClient).SendRexAppearance( |
| 59 |
|
user, avatarServerURL); |
| 60 |
|
} |
| 61 |
|
}); |
| 62 |
|
} |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
public void Initialise(Scene scene, IConfigSource source) |
public void Initialise(Scene scene, IConfigSource source) |
| 68 |
{ |
{ |
| 69 |
|
try |
| 70 |
|
{ |
| 71 |
|
if(!source.Configs["realXtend"].GetBoolean("enabled",false)) |
| 72 |
|
{ |
| 73 |
|
return; |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
m_rexAuthServer = source.Configs["realXtend"].GetString("authentication_server", |
| 77 |
|
m_rexAuthServer); |
| 78 |
|
m_log.Info("RexAppearance Module Being Used"); |
| 79 |
|
} |
| 80 |
|
catch (Exception) |
| 81 |
|
{ |
| 82 |
|
m_log.Info("Rex Config Error, Disabled"); |
| 83 |
|
return; |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
m_scenes.Add(scene); |
| 88 |
|
|
| 89 |
scene.EventManager.OnNewClient += EventManager_OnNewClient; |
scene.EventManager.OnNewClient += EventManager_OnNewClient; |
| 90 |
} |
} |
| 91 |
|
|
| 111 |
|
|
| 112 |
public void PostInitialise() |
public void PostInitialise() |
| 113 |
{ |
{ |
| 114 |
|
m_reqAuthTimer.Elapsed += m_reqAuthTimer_Elapsed; |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
void m_reqAuthTimer_Elapsed(object sender, ElapsedEventArgs e) |
| 118 |
|
{ |
| 119 |
|
while(m_reqAuthQueue.Count > 0) |
| 120 |
|
{ |
| 121 |
|
XmlRpcRequest req; |
| 122 |
|
lock(m_reqAuthQueue) |
| 123 |
|
{ |
| 124 |
|
req = m_reqAuthQueue.Dequeue(); |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
|
| 128 |
|
XmlRpcResponse authreply = req.Send(m_rexAuthServer, 9000); |
| 129 |
|
string rexAsAddress = ((Hashtable) authreply.Value)["as_address"].ToString(); |
| 130 |
|
//string rexSkypeURL = ((Hashtable) authreply.Value)["skype_url"].ToString(); |
| 131 |
|
UUID userID = ((Hashtable) authreply.Value)["uuid"].ToString(); |
| 132 |
|
|
| 133 |
|
SendAppearanceToAllUsers(userID, rexAsAddress); |
| 134 |
|
} |
| 135 |
} |
} |
| 136 |
|
|
| 137 |
public void Close() |
public void Close() |