TestEventQueueGetModule.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.Text;
  33. using System.Threading;
  34. using log4net;
  35. using Nini.Config;
  36. using Mono.Addins;
  37. using OpenMetaverse;
  38. using OpenMetaverse.StructuredData;
  39. using OpenSim.Framework;
  40. using OpenSim.Framework.Servers;
  41. using OpenSim.Region.ClientStack.Linden;
  42. using OpenSim.Region.Framework.Interfaces;
  43. using OpenSim.Region.Framework.Scenes;
  44. namespace OpenSim.Tests.Common
  45. {
  46. public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule
  47. {
  48. public class Event
  49. {
  50. public string Name { get; set; }
  51. public object[] Args { get; set; }
  52. public Event(string name, object[] args)
  53. {
  54. name = Name;
  55. args = Args;
  56. }
  57. }
  58. public Dictionary<UUID, List<Event>> Events { get; set; }
  59. public void Initialise(IConfigSource source) {}
  60. public void Close() {}
  61. public void AddRegion(Scene scene)
  62. {
  63. Events = new Dictionary<UUID, List<Event>>();
  64. scene.RegisterModuleInterface<IEventQueue>(this);
  65. }
  66. public void RemoveRegion (Scene scene) {}
  67. public void RegionLoaded (Scene scene) {}
  68. public string Name { get { return "TestEventQueueGetModule"; } }
  69. public Type ReplaceableInterface { get { return null; } }
  70. private void AddEvent(UUID avatarID, string name, params object[] args)
  71. {
  72. Console.WriteLine("Adding event {0} for {1}", name, avatarID);
  73. List<Event> avEvents;
  74. if (!Events.ContainsKey(avatarID))
  75. {
  76. avEvents = new List<Event>();
  77. Events[avatarID] = avEvents;
  78. }
  79. else
  80. {
  81. avEvents = Events[avatarID];
  82. }
  83. avEvents.Add(new Event(name, args));
  84. }
  85. public void ClearEvents()
  86. {
  87. if (Events != null)
  88. Events.Clear();
  89. }
  90. public bool Enqueue(OSD o, UUID avatarID)
  91. {
  92. AddEvent(avatarID, "Enqueue", o);
  93. return true;
  94. }
  95. /*
  96. public void DisableSimulator(ulong handle, UUID avatarID)
  97. {
  98. AddEvent(avatarID, "DisableSimulator", handle);
  99. }
  100. */
  101. public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
  102. {
  103. AddEvent(avatarID, "EnableSimulator", handle);
  104. }
  105. public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath,
  106. ulong regionHandle, int regionSizeX, int regionSizeY)
  107. {
  108. AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
  109. }
  110. public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
  111. uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY)
  112. {
  113. AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
  114. }
  115. public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint,
  116. string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
  117. {
  118. AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
  119. }
  120. public void ChatterboxInvitation(
  121. UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
  122. byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
  123. UUID transactionID, bool fromGroup, byte[] binaryBucket)
  124. {
  125. AddEvent(
  126. toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
  127. timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
  128. }
  129. public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute , bool isEnterorLeave)
  130. {
  131. AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute, isEnterorLeave);
  132. }
  133. public void ChatterBoxForceClose (UUID toAgent, UUID sessionID, string reason)
  134. {
  135. AddEvent(toAgent, "ForceCloseChatterBoxSession", sessionID, reason);
  136. }
  137. public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
  138. {
  139. AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
  140. }
  141. public void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data)
  142. {
  143. AddEvent(receiverAgent, "AgentGroupDataUpdate", data);
  144. }
  145. public void ScriptRunningEvent (UUID objectID, UUID itemID, bool running, UUID avatarID)
  146. {
  147. Console.WriteLine("ONE");
  148. throw new System.NotImplementedException ();
  149. }
  150. public OSD BuildEvent(string eventName, OSD eventBody)
  151. {
  152. Console.WriteLine("TWO");
  153. throw new System.NotImplementedException ();
  154. }
  155. public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
  156. {
  157. AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
  158. }
  159. public StringBuilder StartEvent(string eventName)
  160. {
  161. return null;
  162. }
  163. public string EndEvent(StringBuilder sb)
  164. {
  165. return "";
  166. }
  167. }
  168. }