aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
diff options
context:
space:
mode:
authorlbsa712009-03-08 19:33:19 +0000
committerlbsa712009-03-08 19:33:19 +0000
commit4f23718102c4d1730a68f0ee85c5604a4dc3d527 (patch)
tree9abb7918cfaf37f4972fcad0fb9a5bbff331e274 /OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
parentMoving Windows Installer to forge. (diff)
downloadopensim-SC_OLD-4f23718102c4d1730a68f0ee85c5604a4dc3d527.zip
opensim-SC_OLD-4f23718102c4d1730a68f0ee85c5604a4dc3d527.tar.gz
opensim-SC_OLD-4f23718102c4d1730a68f0ee85c5604a4dc3d527.tar.bz2
opensim-SC_OLD-4f23718102c4d1730a68f0ee85c5604a4dc3d527.tar.xz
Thank you tlaukkan for a patch that: Upgraded to MXP 0.4 version and cleaned up field naming.
* Updated code to compile against MXP 0.4 version. * Cleaned up field naming conventions. * Added support for logging in with region name. * Filled in new fields of JoinResponseMEssage. * Added support for SynchronizationBeginEvent and SynchronizationEndEvent. * Commented out periodic debug log. * Added networking startup log messages. This closes mantis #3277
Diffstat (limited to 'OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs')
-rw-r--r--OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs151
1 files changed, 87 insertions, 64 deletions
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
index 46d0594..4f77f2c 100644
--- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
+++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
@@ -42,43 +42,43 @@ using OpenSim.Region.Framework.Scenes;
42 42
43namespace OpenSim.Client.MXP.PacketHandler 43namespace OpenSim.Client.MXP.PacketHandler
44{ 44{
45 class MXPPacketServer 45 public class MXPPacketServer
46 { 46 {
47 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private readonly List<MXPClientView> Clients = new List<MXPClientView>();
50 private readonly Dictionary<UUID, Scene> Scenes;
51
52 #region Fields 49 #region Fields
53 50
54 private readonly Transmitter transmitter; 51 private readonly List<MXPClientView> m_clients = new List<MXPClientView>();
52 private readonly Dictionary<UUID, Scene> m_scenes;
53 private readonly Transmitter m_transmitter;
55 54
56 private readonly Thread m_clientThread; 55 private readonly Thread m_clientThread;
57 56
58 private readonly IList<Session> sessions = new List<Session>(); 57 private readonly IList<Session> m_sessions = new List<Session>();
59 private readonly IList<Session> sessionsToClient = new List<Session>(); 58 private readonly IList<Session> m_sessionsToClient = new List<Session>();
60 private readonly IList<MXPClientView> sessionsToRemove = new List<MXPClientView>(); 59 private readonly IList<MXPClientView> m_sessionsToRemove = new List<MXPClientView>();
61 60
62 private readonly String cloudUrl; 61 private readonly int m_port;
63 private readonly String programName; 62 private readonly String m_programName;
64 private readonly byte programMajorVersion; 63 private readonly byte m_programMajorVersion;
65 private readonly byte programMinorVersion; 64 private readonly byte m_programMinorVersion;
66 65
67 #endregion 66 #endregion
68 67
69 #region Constructors 68 #region Constructors
70 69
71 public MXPPacketServer(string cloudUrl, int port, Dictionary<UUID, Scene> scenes) 70 public MXPPacketServer(int port, Dictionary<UUID, Scene> scenes)
72 { 71 {
73 this.cloudUrl = cloudUrl; 72 this.m_port = port;
73
74 m_scenes = scenes;
74 75
75 Scenes = scenes;
76 76
77 programMinorVersion = 63; 77 m_programMinorVersion = 63;
78 programMajorVersion = 0; 78 m_programMajorVersion = 0;
79 programName = "OpenSimulator"; 79 m_programName = "OpenSimulator";
80 80
81 transmitter = new Transmitter(port); 81 m_transmitter = new Transmitter(port);
82 82
83 m_clientThread = new Thread(StartListener); 83 m_clientThread = new Thread(StartListener);
84 m_clientThread.Name = "MXPThread"; 84 m_clientThread.Name = "MXPThread";
@@ -89,7 +89,9 @@ namespace OpenSim.Client.MXP.PacketHandler
89 89
90 public void StartListener() 90 public void StartListener()
91 { 91 {
92 transmitter.Startup(); 92 m_log.Info("[MXP ClientStack] Transmitter starting on UDP server port: " + m_port);
93 m_transmitter.Startup();
94 m_log.Info("[MXP ClientStack] Transmitter started. MXP version: "+MxpConstants.ProtocolMajorVersion+"."+MxpConstants.ProtocolMinorVersion+" Source Revision: "+MxpConstants.ProtocolSourceRevision);
93 } 95 }
94 96
95 #endregion 97 #endregion
@@ -103,7 +105,7 @@ namespace OpenSim.Client.MXP.PacketHandler
103 { 105 {
104 get 106 get
105 { 107 {
106 return transmitter.PendingSessionCount; 108 return m_transmitter.PendingSessionCount;
107 } 109 }
108 } 110 }
109 /// <summary> 111 /// <summary>
@@ -113,7 +115,7 @@ namespace OpenSim.Client.MXP.PacketHandler
113 { 115 {
114 get 116 get
115 { 117 {
116 return sessions.Count; 118 return m_sessions.Count;
117 } 119 }
118 } 120 }
119 /// <summary> 121 /// <summary>
@@ -123,7 +125,7 @@ namespace OpenSim.Client.MXP.PacketHandler
123 { 125 {
124 get 126 get
125 { 127 {
126 return transmitter != null && transmitter.IsAlive; 128 return m_transmitter != null && m_transmitter.IsAlive;
127 } 129 }
128 } 130 }
129 /// <summary> 131 /// <summary>
@@ -133,7 +135,7 @@ namespace OpenSim.Client.MXP.PacketHandler
133 { 135 {
134 get 136 get
135 { 137 {
136 return transmitter != null ? transmitter.PacketsSent : 0; 138 return m_transmitter != null ? m_transmitter.PacketsSent : 0;
137 } 139 }
138 } 140 }
139 /// <summary> 141 /// <summary>
@@ -143,7 +145,7 @@ namespace OpenSim.Client.MXP.PacketHandler
143 { 145 {
144 get 146 get
145 { 147 {
146 return transmitter != null ? transmitter.PacketsReceived : 0; 148 return m_transmitter != null ? m_transmitter.PacketsReceived : 0;
147 } 149 }
148 } 150 }
149 /// <summary> 151 /// <summary>
@@ -153,7 +155,7 @@ namespace OpenSim.Client.MXP.PacketHandler
153 { 155 {
154 get 156 get
155 { 157 {
156 return transmitter != null ? transmitter.BytesReceived : 0; 158 return m_transmitter != null ? m_transmitter.BytesReceived : 0;
157 } 159 }
158 } 160 }
159 /// <summary> 161 /// <summary>
@@ -163,7 +165,7 @@ namespace OpenSim.Client.MXP.PacketHandler
163 { 165 {
164 get 166 get
165 { 167 {
166 return transmitter != null ? transmitter.BytesSent : 0; 168 return m_transmitter != null ? m_transmitter.BytesSent : 0;
167 } 169 }
168 } 170 }
169 /// <summary> 171 /// <summary>
@@ -173,7 +175,7 @@ namespace OpenSim.Client.MXP.PacketHandler
173 { 175 {
174 get 176 get
175 { 177 {
176 return transmitter != null ? transmitter.ReceiveRate : 0; 178 return m_transmitter != null ? m_transmitter.ReceiveRate : 0;
177 } 179 }
178 } 180 }
179 /// <summary> 181 /// <summary>
@@ -183,7 +185,7 @@ namespace OpenSim.Client.MXP.PacketHandler
183 { 185 {
184 get 186 get
185 { 187 {
186 return transmitter != null ? transmitter.SendRate : 0; 188 return m_transmitter != null ? m_transmitter.SendRate : 0;
187 } 189 }
188 } 190 }
189 191
@@ -207,18 +209,17 @@ namespace OpenSim.Client.MXP.PacketHandler
207 209
208 #endregion 210 #endregion
209 211
210
211 #region Processing 212 #region Processing
212 213
213 public void PrintDebugInformation() 214 public void PrintDebugInformation()
214 { 215 {
215 m_log.Info("[MXP ClientStack] Statistics report"); 216 m_log.Info("[MXP ClientStack] Statistics report");
216 m_log.Info("Pending Sessions: " + PendingSessionCount); 217 m_log.Info("Pending Sessions: " + PendingSessionCount);
217 m_log.Info("Sessions: " + SessionCount + " (Clients: " + Clients.Count + " )"); 218 m_log.Info("Sessions: " + SessionCount + " (Clients: " + m_clients.Count + " )");
218 m_log.Info("Transmitter Alive?: " + IsTransmitterAlive); 219 m_log.Info("Transmitter Alive?: " + IsTransmitterAlive);
219 m_log.Info("Packets Sent/Received: " + PacketsSent + " / " + PacketsReceived); 220 m_log.Info("Packets Sent/Received: " + PacketsSent + " / " + PacketsReceived);
220 m_log.Info("Bytes Sent/Received: " + BytesSent + " / " + BytesReceived); 221 m_log.Info("Bytes Sent/Received: " + BytesSent + " / " + BytesReceived);
221 m_log.Info("Send/Recieve Rate (bps): " + SendRate + " / " + ReceiveRate); 222 m_log.Info("Send/Receive Rate (bps): " + SendRate + " / " + ReceiveRate);
222 } 223 }
223 224
224 public void Process() 225 public void Process()
@@ -229,22 +230,22 @@ namespace OpenSim.Client.MXP.PacketHandler
229 230
230 public void Clean() 231 public void Clean()
231 { 232 {
232 foreach (MXPClientView clientView in Clients) 233 foreach (MXPClientView clientView in m_clients)
233 { 234 {
234 if (clientView.Session.SessionState == SessionState.Disconnected) 235 if (clientView.Session.SessionState == SessionState.Disconnected)
235 { 236 {
236 sessionsToRemove.Add(clientView); 237 m_sessionsToRemove.Add(clientView);
237 } 238 }
238 } 239 }
239 240
240 foreach (MXPClientView clientView in sessionsToRemove) 241 foreach (MXPClientView clientView in m_sessionsToRemove)
241 { 242 {
242 clientView.Scene.RemoveClient(clientView.AgentId); 243 clientView.Scene.RemoveClient(clientView.AgentId);
243 Clients.Remove(clientView); 244 m_clients.Remove(clientView);
244 sessions.Remove(clientView.Session); 245 m_sessions.Remove(clientView.Session);
245 } 246 }
246 247
247 sessionsToRemove.Clear(); 248 m_sessionsToRemove.Clear();
248 } 249 }
249 250
250 public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UUID userId, out string firstName, out string lastName) 251 public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UUID userId, out string firstName, out string lastName)
@@ -253,7 +254,7 @@ namespace OpenSim.Client.MXP.PacketHandler
253 firstName = ""; 254 firstName = "";
254 lastName = ""; 255 lastName = "";
255 256
256 if (!Scenes.ContainsKey(sceneId)) 257 if (!m_scenes.ContainsKey(sceneId))
257 { 258 {
258 m_log.Info("Login failed as region was not found: " + sceneId); 259 m_log.Info("Login failed as region was not found: " + sceneId);
259 return false; 260 return false;
@@ -268,7 +269,7 @@ namespace OpenSim.Client.MXP.PacketHandler
268 firstName = nameParts[0]; 269 firstName = nameParts[0];
269 lastName = nameParts[1]; 270 lastName = nameParts[1];
270 271
271 UserProfileData userProfile = Scenes[sceneId].CommsManager.UserService.GetUserProfile(firstName, lastName); 272 UserProfileData userProfile = m_scenes[sceneId].CommsManager.UserService.GetUserProfile(firstName, lastName);
272 if (userProfile == null) 273 if (userProfile == null)
273 { 274 {
274 m_log.Info("Login failed as user was not found: " + participantName); 275 m_log.Info("Login failed as user was not found: " + participantName);
@@ -288,17 +289,17 @@ namespace OpenSim.Client.MXP.PacketHandler
288 289
289 public void ProcessMessages() 290 public void ProcessMessages()
290 { 291 {
291 if (transmitter.PendingSessionCount > 0) 292 if (m_transmitter.PendingSessionCount > 0)
292 { 293 {
293 Session tmp = transmitter.AcceptPendingSession(); 294 Session tmp = m_transmitter.AcceptPendingSession();
294 sessions.Add(tmp); 295 m_sessions.Add(tmp);
295 sessionsToClient.Add(tmp); 296 m_sessionsToClient.Add(tmp);
296 297
297 } 298 }
298 299
299 List<Session> tmpRemove = new List<Session>(); 300 List<Session> tmpRemove = new List<Session>();
300 301
301 foreach (Session session in sessionsToClient) 302 foreach (Session session in m_sessionsToClient)
302 { 303 {
303 while (session.AvailableMessages > 0) 304 while (session.AvailableMessages > 0)
304 { 305 {
@@ -313,13 +314,30 @@ namespace OpenSim.Client.MXP.PacketHandler
313 string firstName; 314 string firstName;
314 string lastName; 315 string lastName;
315 316
317 if (joinRequestMessage.BubbleId == Guid.Empty)
318 {
319 foreach (Scene scene in m_scenes.Values)
320 {
321 if (scene.RegionInfo.RegionName == joinRequestMessage.BubbleName)
322 {
323 m_log.Info("Resolved region by name: " + joinRequestMessage.BubbleName + " (" + scene.RegionInfo.RegionID+")");
324 joinRequestMessage.BubbleId = scene.RegionInfo.RegionID.Guid;
325 }
326 }
327 }
328
329 if (joinRequestMessage.BubbleId == Guid.Empty)
330 {
331 m_log.Warn("Failed to resolve region by name: "+joinRequestMessage.BubbleName);
332 }
333
316 bool authorized = AuthoriseUser(joinRequestMessage.ParticipantName, 334 bool authorized = AuthoriseUser(joinRequestMessage.ParticipantName,
317 joinRequestMessage.ParticipantPassphrase, 335 joinRequestMessage.ParticipantPassphrase,
318 new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName); 336 new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName);
319 337
320 if (authorized) 338 if (authorized)
321 { 339 {
322 Scene target = Scenes[new UUID(joinRequestMessage.BubbleId)]; 340 Scene target = m_scenes[new UUID(joinRequestMessage.BubbleId)];
323 341
324 UUID mxpSessionID = UUID.Random(); 342 UUID mxpSessionID = UUID.Random();
325 343
@@ -332,12 +350,15 @@ namespace OpenSim.Client.MXP.PacketHandler
332 MXPClientView client = new MXPClientView(session, mxpSessionID,userId, target, 350 MXPClientView client = new MXPClientView(session, mxpSessionID,userId, target,
333 firstName, lastName); 351 firstName, lastName);
334 m_log.Info("[MXP ClientStack] Created Client"); 352 m_log.Info("[MXP ClientStack] Created Client");
335 Clients.Add(client); 353 m_clients.Add(client);
336 354
337 m_log.Info("[MXP ClientStack] Adding to Scene"); 355 m_log.Info("[MXP ClientStack] Adding to Scene");
338 target.ClientManager.Add(client.CircuitCode, client); 356 target.ClientManager.Add(client.CircuitCode, client);
339 357
340 m_log.Info("[MXP ClientStack] Initialising..."); 358 m_log.Info("[MXP ClientStack] Initialising...");
359
360 client.MXPSentSynchronizationBegin(m_scenes[new UUID(joinRequestMessage.BubbleId)].SceneContents.GetTotalObjectsCount());
361
341 try 362 try
342 { 363 {
343 client.Start(); 364 client.Start();
@@ -365,10 +386,10 @@ namespace OpenSim.Client.MXP.PacketHandler
365 386
366 foreach (Session session in tmpRemove) 387 foreach (Session session in tmpRemove)
367 { 388 {
368 sessionsToClient.Remove(session); 389 m_sessionsToClient.Remove(session);
369 } 390 }
370 391
371 foreach (MXPClientView clientView in Clients) 392 foreach (MXPClientView clientView in m_clients)
372 { 393 {
373 int messagesProcessedCount = 0; 394 int messagesProcessedCount = 0;
374 Session session = clientView.Session; 395 Session session = clientView.Session;
@@ -431,19 +452,24 @@ namespace OpenSim.Client.MXP.PacketHandler
431 typeof(JoinResponseMessage)); 452 typeof(JoinResponseMessage));
432 453
433 joinResponseMessage.RequestMessageId = joinRequestMessage.MessageId; 454 joinResponseMessage.RequestMessageId = joinRequestMessage.MessageId;
434 joinResponseMessage.FailureCode = 0; 455 joinResponseMessage.FailureCode = MxpResponseCodes.SUCCESS;
435 456
457 joinResponseMessage.BubbleId = joinRequestMessage.BubbleId;
436 joinResponseMessage.ParticipantId = userId.Guid; 458 joinResponseMessage.ParticipantId = userId.Guid;
437 joinResponseMessage.CloudUrl = cloudUrl; 459 joinResponseMessage.AvatarId = userId.Guid;
460 joinResponseMessage.BubbleAssetCacheUrl = m_scenes[new UUID(joinRequestMessage.BubbleId)].CommsManager.NetworkServersInfo.AssetURL;
438 461
439 joinResponseMessage.BubbleName = Scenes[new UUID(joinRequestMessage.BubbleId)].RegionInfo.RegionName; 462 joinResponseMessage.BubbleName = m_scenes[new UUID(joinRequestMessage.BubbleId)].RegionInfo.RegionName;
440 463
464 joinResponseMessage.BubbleRange = 128;
465 joinResponseMessage.BubblePerceptionRange = 128 + 256;
441 joinResponseMessage.BubbleRealTime = 0; 466 joinResponseMessage.BubbleRealTime = 0;
442 joinResponseMessage.ProgramName = programName; 467 joinResponseMessage.ProgramName = m_programName;
443 joinResponseMessage.ProgramMajorVersion = programMajorVersion; 468 joinResponseMessage.ProgramMajorVersion = m_programMajorVersion;
444 joinResponseMessage.ProgramMinorVersion = programMinorVersion; 469 joinResponseMessage.ProgramMinorVersion = m_programMinorVersion;
445 joinResponseMessage.ProtocolMajorVersion = MxpConstants.ProtocolMajorVersion; 470 joinResponseMessage.ProtocolMajorVersion = MxpConstants.ProtocolMajorVersion;
446 joinResponseMessage.ProtocolMinorVersion = MxpConstants.ProtocolMinorVersion; 471 joinResponseMessage.ProtocolMinorVersion = MxpConstants.ProtocolMinorVersion;
472 joinResponseMessage.ProtocolSourceRevision = MxpConstants.ProtocolSourceRevision;
447 473
448 session.Send(joinResponseMessage); 474 session.Send(joinResponseMessage);
449 475
@@ -455,18 +481,14 @@ namespace OpenSim.Client.MXP.PacketHandler
455 JoinResponseMessage joinResponseMessage = (JoinResponseMessage)MessageFactory.Current.ReserveMessage(typeof(JoinResponseMessage)); 481 JoinResponseMessage joinResponseMessage = (JoinResponseMessage)MessageFactory.Current.ReserveMessage(typeof(JoinResponseMessage));
456 482
457 joinResponseMessage.RequestMessageId = joinRequestMessage.MessageId; 483 joinResponseMessage.RequestMessageId = joinRequestMessage.MessageId;
458 joinResponseMessage.FailureCode = 1; 484 joinResponseMessage.FailureCode = MxpResponseCodes.UNAUTHORIZED_OPERATION;
459
460 joinResponseMessage.CloudUrl = cloudUrl;
461 485
462 joinResponseMessage.BubbleName = "Declined OpenSim Region"; // Dont reveal anything about the sim in the disconnect notice 486 joinResponseMessage.ProgramName = m_programName;
463 487 joinResponseMessage.ProgramMajorVersion = m_programMajorVersion;
464 joinResponseMessage.BubbleRealTime = 0; 488 joinResponseMessage.ProgramMinorVersion = m_programMinorVersion;
465 joinResponseMessage.ProgramName = programName;
466 joinResponseMessage.ProgramMajorVersion = programMajorVersion;
467 joinResponseMessage.ProgramMinorVersion = programMinorVersion;
468 joinResponseMessage.ProtocolMajorVersion = MxpConstants.ProtocolMajorVersion; 489 joinResponseMessage.ProtocolMajorVersion = MxpConstants.ProtocolMajorVersion;
469 joinResponseMessage.ProtocolMinorVersion = MxpConstants.ProtocolMinorVersion; 490 joinResponseMessage.ProtocolMinorVersion = MxpConstants.ProtocolMinorVersion;
491 joinResponseMessage.ProtocolSourceRevision = MxpConstants.ProtocolSourceRevision;
470 492
471 session.Send(joinResponseMessage); 493 session.Send(joinResponseMessage);
472 494
@@ -474,5 +496,6 @@ namespace OpenSim.Client.MXP.PacketHandler
474 } 496 }
475 497
476 #endregion 498 #endregion
499
477 } 500 }
478} 501}