aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Mock/TestClient.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs58
1 files changed, 33 insertions, 25 deletions
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 16c55ae..0635aab 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Reflection; 31using System.Reflection;
32using System.Threading;
32using log4net; 33using log4net;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
@@ -41,16 +42,17 @@ namespace OpenSim.Tests.Common.Mock
41 public class TestClient : IClientAPI 42 public class TestClient : IClientAPI
42 { 43 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 45
45 // Mock testing variables 46 // Mock testing variables
46 public List<ImageDataPacket> sentdatapkt = new List<ImageDataPacket>(); 47 public List<ImageDataPacket> sentdatapkt = new List<ImageDataPacket>();
47 public List<ImagePacketPacket> sentpktpkt = new List<ImagePacketPacket>(); 48 public List<ImagePacketPacket> sentpktpkt = new List<ImagePacketPacket>();
48 49 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
50
49 // TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup 51 // TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup
50 // methods on when a teleport is requested 52 // methods on when a teleport is requested
51 public Scene TeleportTargetScene; 53 public Scene TeleportTargetScene;
52 private TestClient TeleportSceneClient; 54 private TestClient TeleportSceneClient;
53 55
54 private IScene m_scene; 56 private IScene m_scene;
55 57
56// disable warning: public events, part of the public API 58// disable warning: public events, part of the public API
@@ -272,7 +274,7 @@ namespace OpenSim.Tests.Common.Mock
272 /// This agent's UUID 274 /// This agent's UUID
273 /// </value> 275 /// </value>
274 private UUID m_agentId; 276 private UUID m_agentId;
275 277
276 /// <value> 278 /// <value>
277 /// The last caps seed url that this client was given. 279 /// The last caps seed url that this client was given.
278 /// </value> 280 /// </value>
@@ -363,15 +365,15 @@ namespace OpenSim.Tests.Common.Mock
363 { 365 {
364 set { } 366 set { }
365 } 367 }
366 368
367 private uint m_circuitCode; 369 private uint m_circuitCode;
368 370
369 public uint CircuitCode 371 public uint CircuitCode
370 { 372 {
371 get { return m_circuitCode; } 373 get { return m_circuitCode; }
372 set { m_circuitCode = value; } 374 set { m_circuitCode = value; }
373 } 375 }
374 376
375 /// <summary> 377 /// <summary>
376 /// Constructor 378 /// Constructor
377 /// </summary> 379 /// </summary>
@@ -386,7 +388,7 @@ namespace OpenSim.Tests.Common.Mock
386 m_scene = scene; 388 m_scene = scene;
387 CapsSeedUrl = agentData.CapsPath; 389 CapsSeedUrl = agentData.CapsPath;
388 } 390 }
389 391
390 /// <summary> 392 /// <summary>
391 /// Attempt a teleport to the given region. 393 /// Attempt a teleport to the given region.
392 /// </summary> 394 /// </summary>
@@ -395,9 +397,9 @@ namespace OpenSim.Tests.Common.Mock
395 /// <param name="lookAt"></param> 397 /// <param name="lookAt"></param>
396 public void Teleport(ulong regionHandle, Vector3 position, Vector3 lookAt) 398 public void Teleport(ulong regionHandle, Vector3 position, Vector3 lookAt)
397 { 399 {
398 OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16); 400 OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16);
399 } 401 }
400 402
401 public void CompleteMovement() 403 public void CompleteMovement()
402 { 404 {
403 OnCompleteMovementToRegion(); 405 OnCompleteMovementToRegion();
@@ -501,46 +503,52 @@ namespace OpenSim.Tests.Common.Mock
501 agentData.child = false; 503 agentData.child = false;
502 agentData.firstname = m_firstName; 504 agentData.firstname = m_firstName;
503 agentData.lastname = m_lastName; 505 agentData.lastname = m_lastName;
504 506
505 ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>(); 507 ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
506 agentData.CapsPath = capsModule.GetCapsPath(m_agentId); 508 agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
507 agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId)); 509 agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
508 510
509 return agentData; 511 return agentData;
510 } 512 }
511 513
512 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) 514 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
513 { 515 {
514 m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour"); 516 m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour");
515 517
516 // In response to this message, we are going to make a teleport to the scene we've previous been told 518 // In response to this message, we are going to make a teleport to the scene we've previous been told
517 // about by test code (this needs to be improved). 519 // about by test code (this needs to be improved).
518 AgentCircuitData newAgent = RequestClientInfo(); 520 AgentCircuitData newAgent = RequestClientInfo();
519 521
520 // Stage 2: add the new client as a child agent to the scene 522 // Stage 2: add the new client as a child agent to the scene
521 TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene); 523 TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene);
522 TeleportTargetScene.AddNewClient(TeleportSceneClient); 524 TeleportTargetScene.AddNewClient(TeleportSceneClient);
523 } 525 }
524 526
525 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, 527 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
526 uint locationID, uint flags, string capsURL) 528 uint locationID, uint flags, string capsURL)
527 { 529 {
528 m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport"); 530 m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport");
529 531
530 CapsSeedUrl = capsURL; 532 CapsSeedUrl = capsURL;
531 533
532 TeleportSceneClient.CompleteMovement(); 534 TeleportSceneClient.CompleteMovement();
533 //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); 535 //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false);
534 } 536 }
535 537
536 public virtual void SendTeleportFailed(string reason) 538 public virtual void SendTeleportFailed(string reason)
537 { 539 {
538 m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); 540 m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason);
539 } 541 }
540 542
541 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, 543 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt,
542 IPEndPoint newRegionExternalEndPoint, string capsURL) 544 IPEndPoint newRegionExternalEndPoint, string capsURL)
543 { 545 {
546 // This is supposed to send a packet to the client telling it's ready to start region crossing.
547 // Instead I will just signal I'm ready, mimicking the communication behavior.
548 // It's ugly, but avoids needless communication setup. This is used in ScenePresenceTests.cs.
549 // Arthur V.
550
551 wh.Set();
544 } 552 }
545 553
546 public virtual void SendMapBlock(List<MapBlockData> mapBlocks, uint flag) 554 public virtual void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
@@ -845,7 +853,7 @@ namespace OpenSim.Tests.Common.Mock
845 public void Start() 853 public void Start()
846 { 854 {
847 } 855 }
848 856
849 public void Stop() 857 public void Stop()
850 { 858 {
851 } 859 }