aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Mock/TestClient.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Tests/Common/Mock/TestClient.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs179
1 files changed, 111 insertions, 68 deletions
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index dde37ab..0e1bc8f 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -38,7 +38,7 @@ using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Framework.Client; 39using OpenSim.Framework.Client;
40 40
41namespace OpenSim.Tests.Common.Mock 41namespace OpenSim.Tests.Common
42{ 42{
43 public class TestClient : IClientAPI, IClientCore 43 public class TestClient : IClientAPI, IClientCore
44 { 44 {
@@ -46,12 +46,10 @@ namespace OpenSim.Tests.Common.Mock
46 46
47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); 47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
48 48
49 private TestClient TeleportSceneClient;
50
51 private Scene m_scene; 49 private Scene m_scene;
52 private SceneManager m_sceneManager;
53 50
54 // Properties so that we can get at received data for test purposes 51 // Properties so that we can get at received data for test purposes
52 public List<uint> ReceivedKills { get; private set; }
55 public List<UUID> ReceivedOfflineNotifications { get; private set; } 53 public List<UUID> ReceivedOfflineNotifications { get; private set; }
56 public List<UUID> ReceivedOnlineNotifications { get; private set; } 54 public List<UUID> ReceivedOnlineNotifications { get; private set; }
57 public List<UUID> ReceivedFriendshipTerminations { get; private set; } 55 public List<UUID> ReceivedFriendshipTerminations { get; private set; }
@@ -60,6 +58,27 @@ namespace OpenSim.Tests.Common.Mock
60 public List<ImagePacketPacket> SentImagePacketPackets { get; private set; } 58 public List<ImagePacketPacket> SentImagePacketPackets { get; private set; }
61 public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; } 59 public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; }
62 60
61 // Test client specific events - for use by tests to implement some IClientAPI behaviour.
62 public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion;
63 public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour;
64 public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport;
65
66 public event Action<ISceneEntity, PrimUpdateFlags> OnReceivedEntityUpdate;
67
68 public event OnReceivedChatMessageDelegate OnReceivedChatMessage;
69 public event Action<GridInstantMessage> OnReceivedInstantMessage;
70
71 public event Action<UUID> OnReceivedSendRebakeAvatarTextures;
72
73 public delegate void TestClientOnSendRegionTeleportDelegate(
74 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
75 uint locationID, uint flags, string capsURL);
76
77 public delegate void OnReceivedChatMessageDelegate(
78 string message, byte type, Vector3 fromPos, string fromName,
79 UUID fromAgentID, UUID ownerID, byte source, byte audible);
80
81
63// disable warning: public events, part of the public API 82// disable warning: public events, part of the public API
64#pragma warning disable 67 83#pragma warning disable 67
65 84
@@ -103,6 +122,7 @@ namespace OpenSim.Tests.Common.Mock
103 public event Action<IClientAPI, bool> OnCompleteMovementToRegion; 122 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
104 public event UpdateAgent OnPreAgentUpdate; 123 public event UpdateAgent OnPreAgentUpdate;
105 public event UpdateAgent OnAgentUpdate; 124 public event UpdateAgent OnAgentUpdate;
125 public event UpdateAgent OnAgentCameraUpdate;
106 public event AgentRequestSit OnAgentRequestSit; 126 public event AgentRequestSit OnAgentRequestSit;
107 public event AgentSit OnAgentSit; 127 public event AgentSit OnAgentSit;
108 public event AvatarPickerRequest OnAvatarPickerRequest; 128 public event AvatarPickerRequest OnAvatarPickerRequest;
@@ -193,6 +213,7 @@ namespace OpenSim.Tests.Common.Mock
193 public event EstateCovenantRequest OnEstateCovenantRequest; 213 public event EstateCovenantRequest OnEstateCovenantRequest;
194 public event EstateChangeInfo OnEstateChangeInfo; 214 public event EstateChangeInfo OnEstateChangeInfo;
195 public event EstateManageTelehub OnEstateManageTelehub; 215 public event EstateManageTelehub OnEstateManageTelehub;
216 public event CachedTextureRequest OnCachedTextureRequest;
196 217
197 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; 218 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
198 219
@@ -430,33 +451,21 @@ namespace OpenSim.Tests.Common.Mock
430 /// <summary> 451 /// <summary>
431 /// Constructor 452 /// Constructor
432 /// </summary> 453 /// </summary>
433 /// <remarks>
434 /// Can be used for a test where there is only one region or where there are multiple regions that are not
435 /// neighbours and where no teleporting takes place. In other situations, the constructor that takes in a
436 /// scene manager should be used.
437 /// </remarks>
438 /// <param name="agentData"></param>
439 /// <param name="scene"></param>
440 public TestClient(AgentCircuitData agentData, Scene scene) : this(agentData, scene, null) {}
441
442 /// <summary>
443 /// Constructor
444 /// </summary>
445 /// <param name="agentData"></param> 454 /// <param name="agentData"></param>
446 /// <param name="scene"></param> 455 /// <param name="scene"></param>
447 /// <param name="sceneManager"></param> 456 /// <param name="sceneManager"></param>
448 public TestClient(AgentCircuitData agentData, Scene scene, SceneManager sceneManager) 457 public TestClient(AgentCircuitData agentData, Scene scene)
449 { 458 {
450 m_agentId = agentData.AgentID; 459 m_agentId = agentData.AgentID;
451 m_firstName = agentData.firstname; 460 m_firstName = agentData.firstname;
452 m_lastName = agentData.lastname; 461 m_lastName = agentData.lastname;
453 m_circuitCode = agentData.circuitcode; 462 m_circuitCode = agentData.circuitcode;
454 m_scene = scene; 463 m_scene = scene;
455 m_sceneManager = sceneManager;
456 SessionId = agentData.SessionID; 464 SessionId = agentData.SessionID;
457 SecureSessionId = agentData.SecureSessionID; 465 SecureSessionId = agentData.SecureSessionID;
458 CapsSeedUrl = agentData.CapsPath; 466 CapsSeedUrl = agentData.CapsPath;
459 467
468 ReceivedKills = new List<uint>();
460 ReceivedOfflineNotifications = new List<UUID>(); 469 ReceivedOfflineNotifications = new List<UUID>();
461 ReceivedOnlineNotifications = new List<UUID>(); 470 ReceivedOnlineNotifications = new List<UUID>();
462 ReceivedFriendshipTerminations = new List<UUID>(); 471 ReceivedFriendshipTerminations = new List<UUID>();
@@ -467,6 +476,34 @@ namespace OpenSim.Tests.Common.Mock
467 } 476 }
468 477
469 /// <summary> 478 /// <summary>
479 /// Trigger chat coming from this connection.
480 /// </summary>
481 /// <param name="channel"></param>
482 /// <param name="type"></param>
483 /// <param name="message"></param>
484 public bool Chat(int channel, ChatTypeEnum type, string message)
485 {
486 ChatMessage handlerChatFromClient = OnChatFromClient;
487
488 if (handlerChatFromClient != null)
489 {
490 OSChatMessage args = new OSChatMessage();
491 args.Channel = channel;
492 args.From = Name;
493 args.Message = message;
494 args.Type = type;
495
496 args.Scene = Scene;
497 args.Sender = this;
498 args.SenderUUID = AgentId;
499
500 handlerChatFromClient(this, args);
501 }
502
503 return true;
504 }
505
506 /// <summary>
470 /// Attempt a teleport to the given region. 507 /// Attempt a teleport to the given region.
471 /// </summary> 508 /// </summary>
472 /// <param name="regionHandle"></param> 509 /// <param name="regionHandle"></param>
@@ -479,7 +516,20 @@ namespace OpenSim.Tests.Common.Mock
479 516
480 public void CompleteMovement() 517 public void CompleteMovement()
481 { 518 {
482 OnCompleteMovementToRegion(this, true); 519 if (OnCompleteMovementToRegion != null)
520 OnCompleteMovementToRegion(this, true);
521 }
522
523 /// <summary>
524 /// Emulate sending an IM from the viewer to the simulator.
525 /// </summary>
526 /// <param name='im'></param>
527 public void HandleImprovedInstantMessage(GridInstantMessage im)
528 {
529 ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
530
531 if (handlerInstantMessage != null)
532 handlerInstantMessage(this, im);
483 } 533 }
484 534
485 public virtual void ActivateGesture(UUID assetId, UUID gestureId) 535 public virtual void ActivateGesture(UUID assetId, UUID gestureId)
@@ -494,6 +544,11 @@ namespace OpenSim.Tests.Common.Mock
494 { 544 {
495 } 545 }
496 546
547 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
548 {
549
550 }
551
497 public virtual void Kick(string message) 552 public virtual void Kick(string message)
498 { 553 {
499 } 554 }
@@ -508,22 +563,22 @@ namespace OpenSim.Tests.Common.Mock
508 563
509 public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) 564 public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
510 { 565 {
511
512 } 566 }
513 567
514 public virtual void SendKillObject(ulong regionHandle, List<uint> localID) 568 public virtual void SendKillObject(List<uint> localID)
515 { 569 {
570 ReceivedKills.AddRange(localID);
516 } 571 }
517 572
518 public virtual void SetChildAgentThrottle(byte[] throttle) 573 public virtual void SetChildAgentThrottle(byte[] throttle)
519 { 574 {
520 } 575 }
576
521 public byte[] GetThrottlesPacked(float multiplier) 577 public byte[] GetThrottlesPacked(float multiplier)
522 { 578 {
523 return new byte[0]; 579 return new byte[0];
524 } 580 }
525 581
526
527 public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) 582 public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
528 { 583 {
529 } 584 }
@@ -532,19 +587,23 @@ namespace OpenSim.Tests.Common.Mock
532 string message, byte type, Vector3 fromPos, string fromName, 587 string message, byte type, Vector3 fromPos, string fromName,
533 UUID fromAgentID, UUID ownerID, byte source, byte audible) 588 UUID fromAgentID, UUID ownerID, byte source, byte audible)
534 { 589 {
590// Console.WriteLine("mmm {0} {1} {2}", message, Name, AgentId);
591 if (OnReceivedChatMessage != null)
592 OnReceivedChatMessage(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible);
535 } 593 }
536 594
537 public void SendInstantMessage(GridInstantMessage im) 595 public void SendInstantMessage(GridInstantMessage im)
538 { 596 {
539 597 if (OnReceivedInstantMessage != null)
598 OnReceivedInstantMessage(im);
540 } 599 }
541 600
542 public void SendGenericMessage(string method, List<string> message) 601 public void SendGenericMessage(string method, UUID invoice, List<string> message)
543 { 602 {
544 603
545 } 604 }
546 605
547 public void SendGenericMessage(string method, List<byte[]> message) 606 public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
548 { 607 {
549 608
550 } 609 }
@@ -566,13 +625,15 @@ namespace OpenSim.Tests.Common.Mock
566 625
567 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 626 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
568 { 627 {
628 if (OnReceivedMoveAgentIntoRegion != null)
629 OnReceivedMoveAgentIntoRegion(regInfo, pos, look);
569 } 630 }
570 631
571 public virtual AgentCircuitData RequestClientInfo() 632 public virtual AgentCircuitData RequestClientInfo()
572 { 633 {
573 AgentCircuitData agentData = new AgentCircuitData(); 634 AgentCircuitData agentData = new AgentCircuitData();
574 agentData.AgentID = AgentId; 635 agentData.AgentID = AgentId;
575 agentData.SessionID = UUID.Zero; 636 agentData.SessionID = SessionId;
576 agentData.SecureSessionID = UUID.Zero; 637 agentData.SecureSessionID = UUID.Zero;
577 agentData.circuitcode = m_circuitCode; 638 agentData.circuitcode = m_circuitCode;
578 agentData.child = false; 639 agentData.child = false;
@@ -591,46 +652,29 @@ namespace OpenSim.Tests.Common.Mock
591 652
592 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) 653 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
593 { 654 {
594 m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour"); 655 if (OnTestClientInformClientOfNeighbour != null)
595 656 OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint);
596 // In response to this message, we are going to make a teleport to the scene we've previous been told
597 // about by test code (this needs to be improved).
598 AgentCircuitData newAgent = RequestClientInfo();
599
600 // Stage 2: add the new client as a child agent to the scene
601 uint x, y;
602 Utils.LongToUInts(neighbourHandle, out x, out y);
603 x /= Constants.RegionSize;
604 y /= Constants.RegionSize;
605
606 Scene neighbourScene;
607 m_sceneManager.TryGetScene(x, y, out neighbourScene);
608
609 TeleportSceneClient = new TestClient(newAgent, neighbourScene, m_sceneManager);
610 neighbourScene.AddNewClient(TeleportSceneClient, PresenceType.User);
611 } 657 }
612 658
613 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, 659 public virtual void SendRegionTeleport(
614 uint locationID, uint flags, string capsURL) 660 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
661 uint locationID, uint flags, string capsURL)
615 { 662 {
616 m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport"); 663 m_log.DebugFormat(
664 "[TEST CLIENT]: Received SendRegionTeleport for {0} {1} on {2}", m_firstName, m_lastName, m_scene.Name);
617 665
618 CapsSeedUrl = capsURL; 666 CapsSeedUrl = capsURL;
619 667
620 // We don't do this here so that the source region can complete processing first in a single-threaded 668 if (OnTestClientSendRegionTeleport != null)
621 // regression test scenario. The test itself will have to call CompleteTeleportClientSide() after a teleport 669 OnTestClientSendRegionTeleport(
622 // CompleteTeleportClientSide(); 670 regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
623 }
624
625 public void CompleteTeleportClientSide()
626 {
627 TeleportSceneClient.CompleteMovement();
628 //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false);
629 } 671 }
630 672
631 public virtual void SendTeleportFailed(string reason) 673 public virtual void SendTeleportFailed(string reason)
632 { 674 {
633 m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); 675 m_log.DebugFormat(
676 "[TEST CLIENT]: Teleport failed for {0} {1} on {2} with reason {3}",
677 m_firstName, m_lastName, m_scene.Name, reason);
634 } 678 }
635 679
636 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, 680 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt,
@@ -660,7 +704,7 @@ namespace OpenSim.Tests.Common.Mock
660 { 704 {
661 } 705 }
662 706
663 public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance) 707 public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
664 { 708 {
665 } 709 }
666 710
@@ -682,6 +726,8 @@ namespace OpenSim.Tests.Common.Mock
682 726
683 public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) 727 public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
684 { 728 {
729 if (OnReceivedEntityUpdate != null)
730 OnReceivedEntityUpdate(entity, updateFlags);
685 } 731 }
686 732
687 public void ReprioritizeUpdates() 733 public void ReprioritizeUpdates()
@@ -786,11 +832,6 @@ namespace OpenSim.Tests.Common.Mock
786 { 832 {
787 OnRegionHandShakeReply(this); 833 OnRegionHandShakeReply(this);
788 } 834 }
789
790 if (OnCompleteMovementToRegion != null)
791 {
792 OnCompleteMovementToRegion(this, true);
793 }
794 } 835 }
795 836
796 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 837 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
@@ -884,11 +925,6 @@ namespace OpenSim.Tests.Common.Mock
884 925
885 } 926 }
886 927
887 public bool AddMoney(int debit)
888 {
889 return false;
890 }
891
892 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) 928 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase)
893 { 929 {
894 } 930 }
@@ -1235,6 +1271,8 @@ namespace OpenSim.Tests.Common.Mock
1235 1271
1236 public void SendRebakeAvatarTextures(UUID textureID) 1272 public void SendRebakeAvatarTextures(UUID textureID)
1237 { 1273 {
1274 if (OnReceivedSendRebakeAvatarTextures != null)
1275 OnReceivedSendRebakeAvatarTextures(textureID);
1238 } 1276 }
1239 1277
1240 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) 1278 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
@@ -1269,12 +1307,17 @@ namespace OpenSim.Tests.Common.Mock
1269 { 1307 {
1270 } 1308 }
1271 1309
1272 public void StopFlying(ISceneEntity presence) 1310 public void SendAgentTerseUpdate(ISceneEntity presence)
1273 { 1311 {
1274 } 1312 }
1275 1313
1276 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) 1314 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data)
1277 { 1315 {
1278 } 1316 }
1317
1318 public void SendPartPhysicsProprieties(ISceneEntity entity)
1319 {
1320 }
1321
1279 } 1322 }
1280} 1323}