Annotation of /trunk/ModularRex/RexNetwork/RexClientView.cs
Parent Directory
|
Revision Log
Revision 10 - (view) (download)
| 1 : | afrisby | 4 | using System.Collections; |
| 2 : | using System.Collections.Generic; | ||
| 3 : | afrisby | 2 | using System.Net; |
| 4 : | afrisby | 4 | using System.Reflection; |
| 5 : | using System.Threading; | ||
| 6 : | using log4net; | ||
| 7 : | using Nwc.XmlRpc; | ||
| 8 : | afrisby | 2 | using OpenMetaverse; |
| 9 : | using OpenSim.Framework; | ||
| 10 : | using OpenSim.Framework.Communications.Cache; | ||
| 11 : | afrisby | 5 | using OpenSim.Region.ClientStack; |
| 12 : | afrisby | 2 | using OpenSim.Region.ClientStack.LindenUDP; |
| 13 : | |||
| 14 : | namespace ModularRex.RexNetwork | ||
| 15 : | { | ||
| 16 : | public delegate void RexAppearanceDelegate(RexClientView sender); | ||
| 17 : | |||
| 18 : | public delegate void RexFaceExpressionDelegate(RexClientView sender, List<string> vParams); | ||
| 19 : | |||
| 20 : | afrisby | 5 | public delegate void RexAvatarProperties(RexClientView sender, List<string> parameters); |
| 21 : | |||
| 22 : | afrisby | 3 | public class RexClientView : LLClientView, IClientRexFaceExpression, IClientRexAppearance |
| 23 : | afrisby | 2 | { |
| 24 : | afrisby | 4 | private static readonly ILog m_log = |
| 25 : | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 26 : | |||
| 27 : | afrisby | 10 | private string m_rexAccountID; |
| 28 : | afrisby | 4 | private string m_rexAvatarURL; |
| 29 : | private string m_rexAuthURL; | ||
| 30 : | private string m_rexSkypeURL; | ||
| 31 : | |||
| 32 : | afrisby | 2 | public event RexAppearanceDelegate OnRexAppearance; |
| 33 : | public event RexFaceExpressionDelegate OnRexFaceExpression; | ||
| 34 : | afrisby | 5 | public event RexAvatarProperties OnRexAvatarProperties; |
| 35 : | afrisby | 2 | |
| 36 : | public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, | ||
| 37 : | afrisby | 6 | LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
| 38 : | afrisby | 5 | UUID sessionId, uint circuitCode, EndPoint proxyEP, ClientStackUserSettings userSettings) |
| 39 : | afrisby | 2 | : base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 40 : | afrisby | 5 | sessionId, circuitCode, proxyEP, userSettings) |
| 41 : | afrisby | 2 | { |
| 42 : | OnGenericMessage += RealXtendClientView_OnGenericMessage; | ||
| 43 : | } | ||
| 44 : | |||
| 45 : | afrisby | 4 | public RexClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, |
| 46 : | afrisby | 6 | LLPacketServer packServer, AuthenticateResponse authenSessions, UUID agentId, |
| 47 : | afrisby | 5 | UUID sessionId, uint circuitCode, EndPoint proxyEP, string rexAvatarURL, string rexAuthURL, ClientStackUserSettings userSettings) |
| 48 : | afrisby | 4 | : base(remoteEP, scene, assetCache, packServer, authenSessions, agentId, |
| 49 : | afrisby | 5 | sessionId, circuitCode, proxyEP, userSettings) |
| 50 : | afrisby | 4 | { |
| 51 : | OnGenericMessage += RealXtendClientView_OnGenericMessage; | ||
| 52 : | |||
| 53 : | RexAvatarURL = rexAvatarURL; | ||
| 54 : | RexAuthURL = rexAuthURL; | ||
| 55 : | } | ||
| 56 : | |||
| 57 : | afrisby | 9 | protected override void RegisterInterfaces() |
| 58 : | { | ||
| 59 : | RegisterInterface<IClientRexAppearance>(this); | ||
| 60 : | RegisterInterface<IClientRexFaceExpression>(this); | ||
| 61 : | RegisterInterface<RexClientView>(this); | ||
| 62 : | |||
| 63 : | base.RegisterInterfaces(); | ||
| 64 : | } | ||
| 65 : | |||
| 66 : | afrisby | 4 | public string RexAvatarURL |
| 67 : | { | ||
| 68 : | get { return m_rexAvatarURL; } | ||
| 69 : | set | ||
| 70 : | { | ||
| 71 : | m_rexAvatarURL = value; | ||
| 72 : | if (OnRexAppearance != null) | ||
| 73 : | { | ||
| 74 : | OnRexAppearance(this); | ||
| 75 : | return; | ||
| 76 : | } | ||
| 77 : | } | ||
| 78 : | } | ||
| 79 : | |||
| 80 : | public string RexSkypeURL | ||
| 81 : | { | ||
| 82 : | get { return m_rexSkypeURL; } | ||
| 83 : | set { m_rexSkypeURL = value; } | ||
| 84 : | } | ||
| 85 : | |||
| 86 : | afrisby | 10 | public string RexAccount |
| 87 : | { | ||
| 88 : | get { return m_rexAccountID; } | ||
| 89 : | set | ||
| 90 : | { | ||
| 91 : | // Todo: More solid data checking here. | ||
| 92 : | m_rexAccountID = value; | ||
| 93 : | RexAuthURL = m_rexAccountID.Split('@')[1]; | ||
| 94 : | } | ||
| 95 : | } | ||
| 96 : | |||
| 97 : | afrisby | 4 | public string RexAuthURL |
| 98 : | { | ||
| 99 : | get { return m_rexAuthURL; } | ||
| 100 : | set | ||
| 101 : | { | ||
| 102 : | m_rexAuthURL = value; | ||
| 103 : | |||
| 104 : | // Request Agent Properties Asynchronously | ||
| 105 : | ThreadPool.QueueUserWorkItem(RequestProperties); | ||
| 106 : | } | ||
| 107 : | } | ||
| 108 : | |||
| 109 : | afrisby | 2 | void RealXtendClientView_OnGenericMessage(object sender, string method, List<string> args) |
| 110 : | { | ||
| 111 : | //TODO: Convert to Dictionary<Method, GenericMessageHandler> | ||
| 112 : | |||
| 113 : | if (method == "RexAppearance") | ||
| 114 : | if (OnRexAppearance != null) | ||
| 115 : | { | ||
| 116 : | OnRexAppearance(this); | ||
| 117 : | return; | ||
| 118 : | } | ||
| 119 : | |||
| 120 : | afrisby | 4 | if (method == "RexFaceExpression") |
| 121 : | afrisby | 2 | { |
| 122 : | afrisby | 4 | if (OnRexFaceExpression != null) |
| 123 : | afrisby | 2 | { |
| 124 : | OnRexFaceExpression(this, args); | ||
| 125 : | afrisby | 5 | return; |
| 126 : | afrisby | 2 | } |
| 127 : | } | ||
| 128 : | afrisby | 5 | |
| 129 : | if (method == "RexAvatarProp") | ||
| 130 : | { | ||
| 131 : | if(OnRexAvatarProperties != null) | ||
| 132 : | { | ||
| 133 : | OnRexAvatarProperties(this, args); | ||
| 134 : | return; | ||
| 135 : | } | ||
| 136 : | } | ||
| 137 : | |||
| 138 : | m_log.Warn("[REXCLIENTVIEW] Unhandled GenericMessage (" + method + ") {"); | ||
| 139 : | foreach (string s in args) | ||
| 140 : | { | ||
| 141 : | m_log.Warn("\t" + s); | ||
| 142 : | } | ||
| 143 : | m_log.Warn("}"); | ||
| 144 : | |||
| 145 : | afrisby | 2 | } |
| 146 : | |||
| 147 : | afrisby | 5 | public void SendRexScriptCommand(string unit, string command, string parameters) |
| 148 : | { | ||
| 149 : | List<string> pack = new List<string>(); | ||
| 150 : | |||
| 151 : | pack.Add(unit); | ||
| 152 : | pack.Add(command); | ||
| 153 : | |||
| 154 : | if (!string.IsNullOrEmpty(parameters)) | ||
| 155 : | pack.Add(parameters); | ||
| 156 : | |||
| 157 : | SendGenericMessage("RexScr", pack); | ||
| 158 : | } | ||
| 159 : | |||
| 160 : | public void SendRexInventoryMessage(string message) | ||
| 161 : | { | ||
| 162 : | SendRexScriptCommand("hud", "ShowInventoryMessage(\"" + message + "\")", ""); | ||
| 163 : | } | ||
| 164 : | |||
| 165 : | afrisby | 6 | public void SendRexScrollMessage(string message, double time) |
| 166 : | { | ||
| 167 : | SendRexScriptCommand("hud", "ShowScrollMessage(\"" + message + "\", \"" + time + "\")", ""); | ||
| 168 : | } | ||
| 169 : | |||
| 170 : | public void SendRexTutorialMessage(string message, double time) | ||
| 171 : | { | ||
| 172 : | SendRexScriptCommand("hud", "ShowScrollMessage(\"" + message + "\", \"" + time + "\")", ""); | ||
| 173 : | } | ||
| 174 : | |||
| 175 : | public void SendRexFadeInAndOut(string message, double between, double time) | ||
| 176 : | { | ||
| 177 : | SendRexScriptCommand("hud", | ||
| 178 : | "ShowInventoryMessage(\"" + message + "\"," | ||
| 179 : | + " \"" + between + "\", \"" + time + "\")", ""); | ||
| 180 : | } | ||
| 181 : | |||
| 182 : | |||
| 183 : | afrisby | 2 | public void SendRexFaceExpression(List<string> expressionData) |
| 184 : | { | ||
| 185 : | expressionData.Insert(0, AgentId.ToString()); | ||
| 186 : | SendGenericMessage("RexFaceExpression", expressionData); | ||
| 187 : | } | ||
| 188 : | |||
| 189 : | public void SendRexAppearance(UUID agentID, string avatarURL) | ||
| 190 : | { | ||
| 191 : | List<string> pack = new List<string>(); | ||
| 192 : | pack.Add(avatarURL); | ||
| 193 : | pack.Add(agentID.ToString()); | ||
| 194 : | |||
| 195 : | SendGenericMessage("RexAppearance", pack); | ||
| 196 : | } | ||
| 197 : | afrisby | 4 | |
| 198 : | /// <summary> | ||
| 199 : | /// Requests properties about this agent from their | ||
| 200 : | /// authentication server. This should be run in | ||
| 201 : | /// an async thread. | ||
| 202 : | /// | ||
| 203 : | /// Note that this particular function may set the | ||
| 204 : | /// avatars appearance which may in turn call | ||
| 205 : | /// additional modules and functions elsewhere. | ||
| 206 : | /// </summary> | ||
| 207 : | /// <param name="o"></param> | ||
| 208 : | private void RequestProperties(object o) | ||
| 209 : | { | ||
| 210 : | m_log.Info("[REXCLIENT] Resolving avatar..."); | ||
| 211 : | Hashtable ReqVals = new Hashtable(); | ||
| 212 : | ReqVals["avatar_uuid"] = AgentId.ToString(); | ||
| 213 : | ReqVals["AuthenticationAddress"] = RexAuthURL; | ||
| 214 : | |||
| 215 : | ArrayList SendParams = new ArrayList(); | ||
| 216 : | SendParams.Add(ReqVals); | ||
| 217 : | |||
| 218 : | XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", SendParams); | ||
| 219 : | |||
| 220 : | m_log.Info("[REXCLIENT] Sending XMLRPC Request to " + RexAuthURL); | ||
| 221 : | XmlRpcResponse authreply = req.Send(RexAuthURL, 9000); | ||
| 222 : | string rexAsAddress = ((Hashtable)authreply.Value)["as_address"].ToString(); | ||
| 223 : | string rexSkypeURL = ((Hashtable)authreply.Value)["skype_url"].ToString(); | ||
| 224 : | UUID userID = new UUID(((Hashtable) authreply.Value)["uuid"].ToString()); | ||
| 225 : | |||
| 226 : | // Sanity check | ||
| 227 : | if (userID == AgentId) | ||
| 228 : | { | ||
| 229 : | RexAvatarURL = rexAsAddress; | ||
| 230 : | RexSkypeURL = rexSkypeURL; | ||
| 231 : | } | ||
| 232 : | } | ||
| 233 : | afrisby | 2 | } |
| 234 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

