TestEventQueueGetModule.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. /*
  95. public void DisableSimulator(ulong handle, UUID avatarID)
  96. {
  97. AddEvent(avatarID, "DisableSimulator", handle);
  98. }
  99. */
  100. public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
  101. {
  102. AddEvent(avatarID, "EnableSimulator", handle);
  103. }
  104. public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath,
  105. ulong regionHandle, int regionSizeX, int regionSizeY)
  106. {
  107. AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
  108. }
  109. public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
  110. uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY)
  111. {
  112. AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
  113. }
  114. public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint,
  115. string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
  116. {
  117. AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
  118. }
  119. public void ChatterboxInvitation(
  120. UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
  121. byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
  122. UUID transactionID, bool fromGroup, byte[] binaryBucket)
  123. {
  124. AddEvent(
  125. toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
  126. timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
  127. }
  128. public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute , bool isEnterorLeave)
  129. {
  130. AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute, isEnterorLeave);
  131. }
  132. public void ChatterBoxForceClose (UUID toAgent, UUID sessionID, string reason)
  133. {
  134. AddEvent(toAgent, "ForceCloseChatterBoxSession", sessionID, reason);
  135. }
  136. public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
  137. {
  138. AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
  139. }
  140. public void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data)
  141. {
  142. AddEvent(receiverAgent, "AgentGroupDataUpdate", data);
  143. }
  144. public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono)
  145. {
  146. Console.WriteLine("ONE");
  147. throw new System.NotImplementedException ();
  148. }
  149. public OSD BuildEvent(string eventName, OSD eventBody)
  150. {
  151. Console.WriteLine("TWO");
  152. throw new System.NotImplementedException ();
  153. }
  154. public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
  155. {
  156. AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
  157. }
  158. }
  159. }