TestEventQueueGetModule.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Reflection;
  32. using System.Threading;
  33. using log4net;
  34. using Nini.Config;
  35. using Mono.Addins;
  36. using OpenMetaverse;
  37. using OpenMetaverse.StructuredData;
  38. using OpenSim.Framework;
  39. using OpenSim.Framework.Servers;
  40. using OpenSim.Region.ClientStack.Linden;
  41. using OpenSim.Region.Framework.Interfaces;
  42. using OpenSim.Region.Framework.Scenes;
  43. namespace OpenSim.Tests.Common
  44. {
  45. public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule
  46. {
  47. public class Event
  48. {
  49. public string Name { get; set; }
  50. public object[] Args { get; set; }
  51. public Event(string name, object[] args)
  52. {
  53. name = Name;
  54. args = Args;
  55. }
  56. }
  57. public Dictionary<UUID, List<Event>> Events { get; set; }
  58. public void Initialise(IConfigSource source) {}
  59. public void Close() {}
  60. public void AddRegion(Scene scene)
  61. {
  62. Events = new Dictionary<UUID, List<Event>>();
  63. scene.RegisterModuleInterface<IEventQueue>(this);
  64. }
  65. public void RemoveRegion (Scene scene) {}
  66. public void RegionLoaded (Scene scene) {}
  67. public string Name { get { return "TestEventQueueGetModule"; } }
  68. public Type ReplaceableInterface { get { return null; } }
  69. private void AddEvent(UUID avatarID, string name, params object[] args)
  70. {
  71. Console.WriteLine("Adding event {0} for {1}", name, avatarID);
  72. List<Event> avEvents;
  73. if (!Events.ContainsKey(avatarID))
  74. {
  75. avEvents = new List<Event>();
  76. Events[avatarID] = avEvents;
  77. }
  78. else
  79. {
  80. avEvents = Events[avatarID];
  81. }
  82. avEvents.Add(new Event(name, args));
  83. }
  84. public void ClearEvents()
  85. {
  86. if (Events != null)
  87. Events.Clear();
  88. }
  89. public bool Enqueue(OSD o, UUID avatarID)
  90. {
  91. AddEvent(avatarID, "Enqueue", o);
  92. return true;
  93. }
  94. public void DisableSimulator(ulong handle, UUID avatarID)
  95. {
  96. AddEvent(avatarID, "DisableSimulator", handle);
  97. }
  98. public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
  99. {
  100. AddEvent(avatarID, "EnableSimulator", handle);
  101. }
  102. public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath,
  103. ulong regionHandle, int regionSizeX, int regionSizeY)
  104. {
  105. AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
  106. }
  107. public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
  108. uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY)
  109. {
  110. AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
  111. }
  112. public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint,
  113. string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
  114. {
  115. AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
  116. }
  117. public void ChatterboxInvitation(
  118. UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
  119. byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
  120. UUID transactionID, bool fromGroup, byte[] binaryBucket)
  121. {
  122. AddEvent(
  123. toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
  124. timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
  125. }
  126. public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute)
  127. {
  128. AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute);
  129. }
  130. public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
  131. {
  132. AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
  133. }
  134. public void GroupMembership (OpenMetaverse.Packets.AgentGroupDataUpdatePacket groupUpdate, UUID avatarID)
  135. {
  136. AddEvent(avatarID, "GroupMembership", groupUpdate);
  137. }
  138. public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono)
  139. {
  140. Console.WriteLine("ONE");
  141. throw new System.NotImplementedException ();
  142. }
  143. public OSD BuildEvent(string eventName, OSD eventBody)
  144. {
  145. Console.WriteLine("TWO");
  146. throw new System.NotImplementedException ();
  147. }
  148. public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
  149. {
  150. AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
  151. }
  152. }
  153. }