aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Client/MXP
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
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')
-rw-r--r--OpenSim/Client/MXP/ClientStack/MXPClientView.cs139
-rw-r--r--OpenSim/Client/MXP/MXPModule.cs52
-rw-r--r--OpenSim/Client/MXP/MXPUtil.cs2
-rw-r--r--OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs151
4 files changed, 202 insertions, 142 deletions
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
index 383ae07..5d08eb0 100644
--- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
+++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
@@ -41,6 +41,7 @@ using Packet=OpenMetaverse.Packets.Packet;
41using MXP.Extentions.OpenMetaverseFragments.Proto; 41using MXP.Extentions.OpenMetaverseFragments.Proto;
42using MXP.Util; 42using MXP.Util;
43using MXP.Fragments; 43using MXP.Fragments;
44using MXP.Common.Proto;
44 45
45namespace OpenSim.Client.MXP.ClientStack 46namespace OpenSim.Client.MXP.ClientStack
46{ 47{
@@ -64,9 +65,10 @@ namespace OpenSim.Client.MXP.ClientStack
64 private readonly IScene m_scene; 65 private readonly IScene m_scene;
65 private readonly string m_firstName; 66 private readonly string m_firstName;
66 private readonly string m_lastName; 67 private readonly string m_lastName;
68 private int m_objectsToSynchronize = 0;
69 private int m_objectsSynchronized = -1;
67 70
68 private Vector3 m_startPosition=new Vector3(128f, 128f, 128f); 71 private Vector3 m_startPosition=new Vector3(128f, 128f, 128f);
69 //private int m_debugLevel;
70 #endregion 72 #endregion
71 73
72 #region Properties 74 #region Properties
@@ -181,7 +183,7 @@ namespace OpenSim.Client.MXP.ClientStack
181 } 183 }
182 else 184 else
183 { 185 {
184 m_log.Warn("[MXP] Received messaged unhandled: " + message); 186 m_log.Warn("[MXP ClientStack] Received messaged unhandled: " + message);
185 } 187 }
186 } 188 }
187 189
@@ -249,7 +251,13 @@ namespace OpenSim.Client.MXP.ClientStack
249 251
250 if (avatarExt.Body != null) 252 if (avatarExt.Body != null)
251 { 253 {
252 agentUpdate.HeadRotation = FromOmQuaternion(avatarExt.Body.HeadOrientation); 254 foreach(OmBipedBoneOrientation boneOrientation in avatarExt.Body.BipedBoneOrientations)
255 {
256 if (boneOrientation.Bone == OmBipedBones.Head)
257 {
258 agentUpdate.HeadRotation = FromOmQuaternion(boneOrientation.Orientation);
259 }
260 }
253 } 261 }
254 else 262 else
255 { 263 {
@@ -295,7 +303,7 @@ namespace OpenSim.Client.MXP.ClientStack
295 private void MXPSendPrimitive(uint localID, UUID ownerID, Vector3 acc, Vector3 rvel, PrimitiveBaseShape primShape, Vector3 pos, UUID objectID, Vector3 vel, Quaternion rotation, uint flags, string text, byte[] textColor, uint parentID, byte[] particleSystem, byte clickAction, byte material, byte[] textureanim) 303 private void MXPSendPrimitive(uint localID, UUID ownerID, Vector3 acc, Vector3 rvel, PrimitiveBaseShape primShape, Vector3 pos, UUID objectID, Vector3 vel, Quaternion rotation, uint flags, string text, byte[] textColor, uint parentID, byte[] particleSystem, byte clickAction, byte material, byte[] textureanim)
296 { 304 {
297 String typeName = ToOmType(primShape.PCode); 305 String typeName = ToOmType(primShape.PCode);
298 m_log.Info("[MXP] Transmitting Primitive" + typeName); 306 m_log.Info("[MXP ClientStack] Transmitting Primitive" + typeName);
299 307
300 PerceptionEventMessage pe = new PerceptionEventMessage(); 308 PerceptionEventMessage pe = new PerceptionEventMessage();
301 309
@@ -307,16 +315,16 @@ namespace OpenSim.Client.MXP.ClientStack
307 pe.ObjectFragment.OwnerId = ownerID.Guid; 315 pe.ObjectFragment.OwnerId = ownerID.Guid;
308 pe.ObjectFragment.TypeId = Guid.Empty; 316 pe.ObjectFragment.TypeId = Guid.Empty;
309 pe.ObjectFragment.TypeName = typeName; 317 pe.ObjectFragment.TypeName = typeName;
310 pe.ObjectFragment.Acceleration = new float[] { acc.X, acc.Y, acc.Z }; 318 pe.ObjectFragment.Acceleration = ToOmVector(acc);
311 pe.ObjectFragment.AngularAcceleration = new float[4]; 319 pe.ObjectFragment.AngularAcceleration=new MsdQuaternion4f();
312 pe.ObjectFragment.AngularVelocity = new float[] { rvel.X, rvel.Y, rvel.Z, 0.0f }; 320 pe.ObjectFragment.AngularVelocity = ToOmQuaternion(rvel);
313 pe.ObjectFragment.BoundingSphereRadius = primShape.Scale.Length(); 321 pe.ObjectFragment.BoundingSphereRadius = primShape.Scale.Length();
314 322
315 pe.ObjectFragment.Location = new float[] { pos.X, pos.Y, pos.Z }; 323 pe.ObjectFragment.Location = ToOmVector(pos);
316 324
317 pe.ObjectFragment.Mass = 1.0f; 325 pe.ObjectFragment.Mass = 1.0f;
318 pe.ObjectFragment.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; 326 pe.ObjectFragment.Orientation = ToOmQuaternion(rotation);
319 pe.ObjectFragment.Velocity = new float[] { vel.X, vel.Y, vel.Z }; 327 pe.ObjectFragment.Velocity =ToOmVector(vel);
320 328
321 OmSlPrimitiveExt ext = new OmSlPrimitiveExt(); 329 OmSlPrimitiveExt ext = new OmSlPrimitiveExt();
322 330
@@ -360,11 +368,23 @@ namespace OpenSim.Client.MXP.ClientStack
360 pe.SetExtension<OmSlPrimitiveExt>(ext); 368 pe.SetExtension<OmSlPrimitiveExt>(ext);
361 369
362 Session.Send(pe); 370 Session.Send(pe);
371
372 if (m_objectsSynchronized != -1)
373 {
374 m_objectsSynchronized++;
375
376 if (m_objectsToSynchronize >= m_objectsSynchronized)
377 {
378 SynchronizationEndEventMessage synchronizationEndEventMessage = new SynchronizationEndEventMessage();
379 Session.Send(synchronizationEndEventMessage);
380 m_objectsSynchronized = -1;
381 }
382 }
363 } 383 }
364 384
365 public void MXPSendAvatarData(string participantName, UUID ownerID, UUID parentId, UUID avatarID, uint avatarLocalID, Vector3 position, Quaternion rotation) 385 public void MXPSendAvatarData(string participantName, UUID ownerID, UUID parentId, UUID avatarID, uint avatarLocalID, Vector3 position, Quaternion rotation)
366 { 386 {
367 m_log.Info("[MXP] Transmitting Avatar Data " + participantName); 387 m_log.Info("[MXP ClientStack] Transmitting Avatar Data " + participantName);
368 388
369 PerceptionEventMessage pe = new PerceptionEventMessage(); 389 PerceptionEventMessage pe = new PerceptionEventMessage();
370 390
@@ -376,23 +396,23 @@ namespace OpenSim.Client.MXP.ClientStack
376 pe.ObjectFragment.OwnerId = ownerID.Guid; 396 pe.ObjectFragment.OwnerId = ownerID.Guid;
377 pe.ObjectFragment.TypeId = Guid.Empty; 397 pe.ObjectFragment.TypeId = Guid.Empty;
378 pe.ObjectFragment.TypeName = "Avatar"; 398 pe.ObjectFragment.TypeName = "Avatar";
379 pe.ObjectFragment.Acceleration = new float[3]; 399 pe.ObjectFragment.Acceleration = new MsdVector3f();
380 pe.ObjectFragment.AngularAcceleration = new float[4]; 400 pe.ObjectFragment.AngularAcceleration = new MsdQuaternion4f();
381 pe.ObjectFragment.AngularVelocity = new float[4]; 401 pe.ObjectFragment.AngularVelocity = new MsdQuaternion4f();
382 pe.ObjectFragment.BoundingSphereRadius = 1; // TODO Fill in appropriate value 402 pe.ObjectFragment.BoundingSphereRadius = 1; // TODO Fill in appropriate value
383 403
384 pe.ObjectFragment.Location = new float[] { position.X, position.Y, position.Z }; 404 pe.ObjectFragment.Location = ToOmVector(position);
385 405
386 pe.ObjectFragment.Mass = 1.0f; // TODO Fill in appropriate value 406 pe.ObjectFragment.Mass = 1.0f; // TODO Fill in appropriate value
387 pe.ObjectFragment.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; 407 pe.ObjectFragment.Orientation = ToOmQuaternion(rotation);
388 pe.ObjectFragment.Velocity = new float[3]; 408 pe.ObjectFragment.Velocity = new MsdVector3f();
389 409
390 Session.Send(pe); 410 Session.Send(pe);
391 } 411 }
392 412
393 public void MXPSendTerrain(float[] map) 413 public void MXPSendTerrain(float[] map)
394 { 414 {
395 m_log.Info("[MXP] Transmitting terrain for " + m_scene.RegionInfo.RegionName); 415 m_log.Info("[MXP ClientStack] Transmitting terrain for " + m_scene.RegionInfo.RegionName);
396 416
397 PerceptionEventMessage pe = new PerceptionEventMessage(); 417 PerceptionEventMessage pe = new PerceptionEventMessage();
398 418
@@ -404,16 +424,16 @@ namespace OpenSim.Client.MXP.ClientStack
404 pe.ObjectFragment.OwnerId = m_scene.RegionInfo.MasterAvatarAssignedUUID.Guid; 424 pe.ObjectFragment.OwnerId = m_scene.RegionInfo.MasterAvatarAssignedUUID.Guid;
405 pe.ObjectFragment.TypeId = Guid.Empty; 425 pe.ObjectFragment.TypeId = Guid.Empty;
406 pe.ObjectFragment.TypeName = "Terrain"; 426 pe.ObjectFragment.TypeName = "Terrain";
407 pe.ObjectFragment.Acceleration = new float[3]; 427 pe.ObjectFragment.Acceleration = new MsdVector3f();
408 pe.ObjectFragment.AngularAcceleration = new float[4]; 428 pe.ObjectFragment.AngularAcceleration = new MsdQuaternion4f();
409 pe.ObjectFragment.AngularVelocity = new float[4]; 429 pe.ObjectFragment.AngularVelocity = new MsdQuaternion4f();
410 pe.ObjectFragment.BoundingSphereRadius = 1; // TODO Fill in appropriate value 430 pe.ObjectFragment.BoundingSphereRadius = 1; // TODO Fill in appropriate value
411 431
412 pe.ObjectFragment.Location = new float[] { 0, 0, 0 }; 432 pe.ObjectFragment.Location = new MsdVector3f();
413 433
414 pe.ObjectFragment.Mass = 1.0f; // TODO Fill in appropriate value 434 pe.ObjectFragment.Mass = 1.0f; // TODO Fill in appropriate value
415 pe.ObjectFragment.Orientation = new float[] { 0, 0, 0, 0 }; 435 pe.ObjectFragment.Orientation = new MsdQuaternion4f();
416 pe.ObjectFragment.Velocity = new float[3]; 436 pe.ObjectFragment.Velocity = new MsdVector3f();
417 437
418 OmBitmapTerrainExt terrainExt = new OmBitmapTerrainExt(); 438 OmBitmapTerrainExt terrainExt = new OmBitmapTerrainExt();
419 terrainExt.Width = 256; 439 terrainExt.Width = 256;
@@ -421,37 +441,68 @@ namespace OpenSim.Client.MXP.ClientStack
421 terrainExt.WaterLevel = (float) m_scene.RegionInfo.RegionSettings.WaterHeight; 441 terrainExt.WaterLevel = (float) m_scene.RegionInfo.RegionSettings.WaterHeight;
422 terrainExt.Offset = 0; 442 terrainExt.Offset = 0;
423 terrainExt.Scale = 10; 443 terrainExt.Scale = 10;
424 terrainExt.HeightMap = CompressionUtil.CompressHeightMap(map, 0, 10); 444 terrainExt.HeightMap = CompressUtil.CompressHeightMap(map, 0, 10);
425 445
426 pe.SetExtension<OmBitmapTerrainExt>(terrainExt); 446 pe.SetExtension<OmBitmapTerrainExt>(terrainExt);
427 447
428 Session.Send(pe); 448 Session.Send(pe);
429 } 449 }
430 450
451 public void MXPSentSynchronizationBegin(int objectCount)
452 {
453 m_objectsToSynchronize = objectCount;
454 m_objectsSynchronized = 0;
455 SynchronizationBeginEventMessage synchronizationBeginEventMessage = new SynchronizationBeginEventMessage();
456 synchronizationBeginEventMessage.ObjectCount = (uint)objectCount;
457 Session.Send(synchronizationBeginEventMessage);
458 }
459
431 #endregion 460 #endregion
432 461
433 #region MXP Conversions 462 #region MXP Conversions
434 463
435 private OmVector3f ToOmVector(Vector3 value) 464 private MsdVector3f ToOmVector(Vector3 value)
465 {
466 MsdVector3f encodedValue = new MsdVector3f();
467 encodedValue.X = value.X;
468 encodedValue.Y = value.Y;
469 encodedValue.Z = value.Z;
470 return encodedValue;
471 }
472
473 private MsdQuaternion4f ToOmQuaternion(Vector3 value)
474 {
475 Quaternion quaternion=Quaternion.CreateFromEulers(value);
476 MsdQuaternion4f encodedValue = new MsdQuaternion4f();
477 encodedValue.X = quaternion.X;
478 encodedValue.Y = quaternion.Y;
479 encodedValue.Z = quaternion.Z;
480 encodedValue.W = quaternion.W;
481 return encodedValue;
482 }
483
484 private MsdQuaternion4f ToOmQuaternion(Quaternion value)
436 { 485 {
437 OmVector3f encodedValue = new OmVector3f(); 486 MsdQuaternion4f encodedValue = new MsdQuaternion4f();
438 encodedValue.X = value.X; 487 encodedValue.X = value.X;
439 encodedValue.Y = value.Y; 488 encodedValue.Y = value.Y;
440 encodedValue.Z = value.Z; 489 encodedValue.Z = value.Z;
490 encodedValue.W = value.W;
441 return encodedValue; 491 return encodedValue;
442 } 492 }
443 493
444 private Vector3 FromOmVector(OmVector3f vector) 494 private Vector3 FromOmVector(MsdVector3f vector)
445 { 495 {
446 return new Vector3(vector.X, vector.Y, vector.Z); 496 return new Vector3(vector.X, vector.Y, vector.Z);
447 } 497 }
448 498
499
449 private Vector3 FromOmVector(float[] vector) 500 private Vector3 FromOmVector(float[] vector)
450 { 501 {
451 return new Vector3(vector[0], vector[1], vector[2]); 502 return new Vector3(vector[0], vector[1], vector[2]);
452 } 503 }
453 504
454 private Quaternion FromOmQuaternion(OmQuaternion4f quaternion) 505 private Quaternion FromOmQuaternion(MsdQuaternion4f quaternion)
455 { 506 {
456 return new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W); 507 return new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
457 } 508 }
@@ -461,9 +512,9 @@ namespace OpenSim.Client.MXP.ClientStack
461 return new Quaternion(quaternion[0], quaternion[1], quaternion[2], quaternion[3]); 512 return new Quaternion(quaternion[0], quaternion[1], quaternion[2], quaternion[3]);
462 } 513 }
463 514
464 private OmColor4f ToOmColor(byte[] value) 515 private MsdColor4f ToOmColor(byte[] value)
465 { 516 {
466 OmColor4f encodedValue = new OmColor4f(); 517 MsdColor4f encodedValue = new MsdColor4f();
467 encodedValue.R = value[0]; 518 encodedValue.R = value[0];
468 encodedValue.G = value[1]; 519 encodedValue.G = value[1];
469 encodedValue.B = value[2]; 520 encodedValue.B = value[2];
@@ -750,18 +801,6 @@ namespace OpenSim.Client.MXP.ClientStack
750 public void Start() 801 public void Start()
751 { 802 {
752 Scene.AddNewClient(this); 803 Scene.AddNewClient(this);
753 /*foreach (ScenePresence presence in ((Scene)Scene).GetScenePresences())
754 {
755 if (presence.Appearance!=null)
756 {
757 AvatarAppearance avatar = presence.Appearance;
758 if (presence.Appearance.Owner == m_userID)
759 {
760 MXPSendAvatarData(m_firstName + " " + m_lastName, presence.Appearance.Owner, UUID.Zero, presence.UUID, presence.LocalId, presence.AbsolutePosition, presence.Rotation);
761 }
762 }
763 }*/
764
765 } 804 }
766 805
767 public void Stop() 806 public void Stop()
@@ -799,7 +838,7 @@ namespace OpenSim.Client.MXP.ClientStack
799 838
800 public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) 839 public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
801 { 840 {
802 m_log.Info("[MXP] Completing Handshake to Region"); 841 m_log.Info("[MXP ClientStack] Completing Handshake to Region");
803 842
804 if (OnRegionHandShakeReply != null) 843 if (OnRegionHandShakeReply != null)
805 { 844 {
@@ -820,9 +859,8 @@ namespace OpenSim.Client.MXP.ClientStack
820 chatActionEvent.ActionFragment.ActionName = "Chat"; 859 chatActionEvent.ActionFragment.ActionName = "Chat";
821 chatActionEvent.ActionFragment.SourceObjectId = fromAgentID.Guid; 860 chatActionEvent.ActionFragment.SourceObjectId = fromAgentID.Guid;
822 chatActionEvent.ActionFragment.ObservationRadius = 180.0f; 861 chatActionEvent.ActionFragment.ObservationRadius = 180.0f;
823 chatActionEvent.ActionFragment.ActionPayloadDialect = "TEXT"; 862 chatActionEvent.ActionFragment.ExtensionDialect = "TEXT";
824 chatActionEvent.SetPayloadData(Encoding.UTF8.GetBytes(message)); 863 chatActionEvent.SetPayloadData(Encoding.UTF8.GetBytes(message));
825 chatActionEvent.ActionFragment.ActionPayloadLength = (uint)chatActionEvent.GetPayloadData().Length;
826 864
827 Session.Send(chatActionEvent); 865 Session.Send(chatActionEvent);
828 } 866 }
@@ -938,8 +976,8 @@ namespace OpenSim.Client.MXP.ClientStack
938 { 976 {
939 MovementEventMessage me = new MovementEventMessage(); 977 MovementEventMessage me = new MovementEventMessage();
940 me.ObjectIndex = localID; 978 me.ObjectIndex = localID;
941 me.Location = new float[] { position.X, position.Y, position.Z }; 979 me.Location =ToOmVector(position);
942 me.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; 980 me.Orientation = ToOmQuaternion(rotation);
943 981
944 Session.Send(me); 982 Session.Send(me);
945 } 983 }
@@ -973,9 +1011,8 @@ namespace OpenSim.Client.MXP.ClientStack
973 { 1011 {
974 MovementEventMessage me = new MovementEventMessage(); 1012 MovementEventMessage me = new MovementEventMessage();
975 me.ObjectIndex = localID; 1013 me.ObjectIndex = localID;
976 me.Location = new float[] {position.X, position.Y, position.Z}; 1014 me.Location = ToOmVector(position);
977 me.Orientation = new float[] {rotation.X, rotation.Y, rotation.Z, rotation.W}; 1015 me.Orientation = ToOmQuaternion(rotation);
978
979 Session.Send(me); 1016 Session.Send(me);
980 } 1017 }
981 1018
diff --git a/OpenSim/Client/MXP/MXPModule.cs b/OpenSim/Client/MXP/MXPModule.cs
index 581239f..e0891ca 100644
--- a/OpenSim/Client/MXP/MXPModule.cs
+++ b/OpenSim/Client/MXP/MXPModule.cs
@@ -40,65 +40,64 @@ namespace OpenSim.Client.MXP
40{ 40{
41 public class MXPModule : IRegionModule 41 public class MXPModule : IRegionModule
42 { 42 {
43 private int mxp_Port = 1253;
44 //private double mxp_BubbleRadius = 181.01933598375616624661615669884; // Radius of a sphere big enough to encapsulate a 256x256 square
45 43
46 private readonly Timer ticker = new Timer(100); 44 private int m_port = 1253;
45 //private int m_ticks = 0;
46 private bool m_shutdown = false;
47 47
48 private int ticks; 48 private IConfigSource m_config;
49 private bool shutdown = false; 49 private readonly Timer m_ticker = new Timer(100);
50 50 private readonly Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
51 private IConfigSource config;
52
53 private readonly Dictionary<UUID,Scene> m_scenes = new Dictionary<UUID, Scene>();
54
55 private MXPPacketServer server;
56 51
52 private MXPPacketServer m_server;
57 53
58 public void Initialise(Scene scene, IConfigSource source) 54 public void Initialise(Scene scene, IConfigSource source)
59 { 55 {
60 if (!m_scenes.ContainsKey(scene.RegionInfo.RegionID)) 56 if (!m_scenes.ContainsKey(scene.RegionInfo.RegionID))
61 m_scenes.Add(scene.RegionInfo.RegionID, scene); 57 m_scenes.Add(scene.RegionInfo.RegionID, scene);
62 config = source; 58
59 m_config = source;
63 } 60 }
64 61
65 public void PostInitialise() 62 public void PostInitialise()
66 { 63 {
67 if (config.Configs["MXP"] != null) 64 if (m_config.Configs["MXP"] != null)
68 { 65 {
69 IConfig con = config.Configs["MXP"]; 66 IConfig con = m_config.Configs["MXP"];
70 67
71 if (!con.GetBoolean("Enabled", false)) 68 if (!con.GetBoolean("Enabled", false))
72 return; 69 return;
73 70
74 mxp_Port = con.GetInt("Port", mxp_Port); 71 m_port = con.GetInt("Port", m_port);
75 72
76 server = new MXPPacketServer("http://null", mxp_Port, m_scenes); 73 m_server = new MXPPacketServer(m_port, m_scenes);
77 74
78 ticker.AutoReset = false; 75 m_ticker.AutoReset = false;
79 ticker.Elapsed += ticker_Elapsed; 76 m_ticker.Elapsed += ticker_Elapsed;
80 77
81 ticker.Start(); 78 m_ticker.Start();
82 } 79 }
83 } 80 }
84 81
85 void ticker_Elapsed(object sender, ElapsedEventArgs e) 82 void ticker_Elapsed(object sender, ElapsedEventArgs e)
86 { 83 {
87 server.Process(); 84 m_server.Process();
88 85
89 if (!shutdown) 86 if (!m_shutdown)
90 ticker.Start(); 87 m_ticker.Start();
91 88
92 if (++ticks % 100 == 0) 89 // Commenting this at because of the excess flood to log.
90 // TODO: Add ini file option.
91 /*if (++ticks % 100 == 0)
93 { 92 {
94 server.PrintDebugInformation(); 93 server.PrintDebugInformation();
95 } 94 }*/
96 } 95 }
97 96
98 public void Close() 97 public void Close()
99 { 98 {
100 shutdown = true; 99 m_shutdown = true;
101 ticker.Stop(); 100 m_ticker.Stop();
102 } 101 }
103 102
104 public string Name 103 public string Name
@@ -110,5 +109,6 @@ namespace OpenSim.Client.MXP
110 { 109 {
111 get { return true; } 110 get { return true; }
112 } 111 }
112
113 } 113 }
114} 114}
diff --git a/OpenSim/Client/MXP/MXPUtil.cs b/OpenSim/Client/MXP/MXPUtil.cs
index cbf2eac..3387145 100644
--- a/OpenSim/Client/MXP/MXPUtil.cs
+++ b/OpenSim/Client/MXP/MXPUtil.cs
@@ -32,7 +32,7 @@ using OpenMetaverse;
32 32
33namespace OpenSim.Client.MXP 33namespace OpenSim.Client.MXP
34{ 34{
35 static class MXPUtil 35 public static class MXPUtil
36 { 36 {
37 public static string GenerateMXPURL(string server, int port, UUID bubbleID, Vector3 location) 37 public static string GenerateMXPURL(string server, int port, UUID bubbleID, Vector3 location)
38 { 38 {
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}