diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestClient.cs | 79 |
1 files changed, 61 insertions, 18 deletions
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 5b3b27b..6254272 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -28,6 +28,8 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Reflection; | ||
32 | using log4net; | ||
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | using OpenMetaverse.Packets; | 34 | using OpenMetaverse.Packets; |
33 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -37,11 +39,18 @@ namespace OpenSim.Tests.Common.Mock | |||
37 | { | 39 | { |
38 | public class TestClient : IClientAPI | 40 | public class TestClient : IClientAPI |
39 | { | 41 | { |
40 | private Scene m_scene; | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 43 | ||
42 | // Mock testing variables | 44 | // Mock testing variables |
43 | public List<ImageDataPacket> sentdatapkt = new List<ImageDataPacket>(); | 45 | public List<ImageDataPacket> sentdatapkt = new List<ImageDataPacket>(); |
44 | public List<ImagePacketPacket> sentpktpkt = new List<ImagePacketPacket>(); | 46 | public List<ImagePacketPacket> sentpktpkt = new List<ImagePacketPacket>(); |
47 | |||
48 | // TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup | ||
49 | // methods on when a teleport is requested | ||
50 | public Scene TeleportTargetScene; | ||
51 | private TestClient TeleportSceneClient; | ||
52 | |||
53 | private IScene m_scene; | ||
45 | 54 | ||
46 | // disable warning: public events, part of the public API | 55 | // disable warning: public events, part of the public API |
47 | #pragma warning disable 67 | 56 | #pragma warning disable 67 |
@@ -259,7 +268,7 @@ namespace OpenSim.Tests.Common.Mock | |||
259 | /// <value> | 268 | /// <value> |
260 | /// This agent's UUID | 269 | /// This agent's UUID |
261 | /// </value> | 270 | /// </value> |
262 | private UUID myID; | 271 | private UUID m_agentId; |
263 | 272 | ||
264 | private Vector3 startPos = new Vector3(128, 128, 2); | 273 | private Vector3 startPos = new Vector3(128, 128, 2); |
265 | 274 | ||
@@ -271,7 +280,7 @@ namespace OpenSim.Tests.Common.Mock | |||
271 | 280 | ||
272 | public virtual UUID AgentId | 281 | public virtual UUID AgentId |
273 | { | 282 | { |
274 | get { return myID; } | 283 | get { return m_agentId; } |
275 | } | 284 | } |
276 | 285 | ||
277 | public UUID SessionId | 286 | public UUID SessionId |
@@ -359,11 +368,14 @@ namespace OpenSim.Tests.Common.Mock | |||
359 | /// Constructor | 368 | /// Constructor |
360 | /// </summary> | 369 | /// </summary> |
361 | /// <param name="agentData"></param> | 370 | /// <param name="agentData"></param> |
362 | public TestClient(AgentCircuitData agentData) | 371 | /// <param name="scene"></param> |
372 | public TestClient(AgentCircuitData agentData, IScene scene) | ||
363 | { | 373 | { |
364 | myID = agentData.AgentID; | 374 | m_agentId = agentData.AgentID; |
365 | m_firstName = agentData.firstname; | 375 | m_firstName = agentData.firstname; |
366 | m_lastName = agentData.lastname; | 376 | m_lastName = agentData.lastname; |
377 | m_circuitCode = agentData.circuitcode; | ||
378 | m_scene = scene; | ||
367 | } | 379 | } |
368 | 380 | ||
369 | /// <summary> | 381 | /// <summary> |
@@ -376,6 +388,11 @@ namespace OpenSim.Tests.Common.Mock | |||
376 | { | 388 | { |
377 | OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16); | 389 | OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16); |
378 | } | 390 | } |
391 | |||
392 | public void CompleteMovement() | ||
393 | { | ||
394 | OnCompleteMovementToRegion(); | ||
395 | } | ||
379 | 396 | ||
380 | public virtual void ActivateGesture(UUID assetId, UUID gestureId) | 397 | public virtual void ActivateGesture(UUID assetId, UUID gestureId) |
381 | { | 398 | { |
@@ -465,14 +482,48 @@ namespace OpenSim.Tests.Common.Mock | |||
465 | { | 482 | { |
466 | } | 483 | } |
467 | 484 | ||
485 | public virtual AgentCircuitData RequestClientInfo() | ||
486 | { | ||
487 | AgentCircuitData agentData = new AgentCircuitData(); | ||
488 | agentData.AgentID = AgentId; | ||
489 | agentData.SessionID = UUID.Zero; | ||
490 | agentData.SecureSessionID = UUID.Zero; | ||
491 | agentData.circuitcode = m_circuitCode; | ||
492 | agentData.child = false; | ||
493 | agentData.firstname = m_firstName; | ||
494 | agentData.lastname = m_lastName; | ||
495 | agentData.CapsPath = m_scene.GetCapsPath(m_agentId); | ||
496 | agentData.ChildrenCapSeeds = new Dictionary<ulong,string>(m_scene.GetChildrenSeeds(m_agentId)); | ||
497 | |||
498 | return agentData; | ||
499 | } | ||
500 | |||
468 | public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) | 501 | public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) |
469 | { | 502 | { |
503 | m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour"); | ||
504 | |||
505 | // In response to this message, we are going to make a teleport to the scene we've previous been told | ||
506 | // about by test code (this needs to be improved). | ||
507 | AgentCircuitData newAgent = RequestClientInfo(); | ||
508 | |||
509 | // Stage 2: add the new client as a child agent to the scene | ||
510 | TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene); | ||
511 | TeleportTargetScene.AddNewClient(TeleportSceneClient); | ||
512 | } | ||
513 | |||
514 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | ||
515 | uint locationID, uint flags, string capsURL) | ||
516 | { | ||
517 | m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport"); | ||
518 | |||
519 | TeleportSceneClient.CompleteMovement(); | ||
520 | //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); | ||
470 | } | 521 | } |
471 | 522 | ||
472 | public virtual AgentCircuitData RequestClientInfo() | 523 | public virtual void SendTeleportFailed(string reason) |
473 | { | 524 | { |
474 | return new AgentCircuitData(); | 525 | m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); |
475 | } | 526 | } |
476 | 527 | ||
477 | public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, | 528 | public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, |
478 | IPEndPoint newRegionExternalEndPoint, string capsURL) | 529 | IPEndPoint newRegionExternalEndPoint, string capsURL) |
@@ -487,15 +538,6 @@ namespace OpenSim.Tests.Common.Mock | |||
487 | { | 538 | { |
488 | } | 539 | } |
489 | 540 | ||
490 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | ||
491 | uint locationID, uint flags, string capsURL) | ||
492 | { | ||
493 | } | ||
494 | |||
495 | public virtual void SendTeleportFailed(string reason) | ||
496 | { | ||
497 | } | ||
498 | |||
499 | public virtual void SendTeleportLocationStart() | 541 | public virtual void SendTeleportLocationStart() |
500 | { | 542 | { |
501 | } | 543 | } |
@@ -788,6 +830,7 @@ namespace OpenSim.Tests.Common.Mock | |||
788 | 830 | ||
789 | public void Close(bool ShutdownCircuit) | 831 | public void Close(bool ShutdownCircuit) |
790 | { | 832 | { |
833 | m_scene.RemoveClient(AgentId); | ||
791 | } | 834 | } |
792 | 835 | ||
793 | public void Start() | 836 | public void Start() |