TestEventQueueGetModule.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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(string o, UUID avatarID)
  91. {
  92. AddEvent(avatarID, "Enqueue", o);
  93. return true;
  94. }
  95. public bool Enqueue(byte[] o, UUID avatarID)
  96. {
  97. return true;
  98. }
  99. public bool Enqueue(OSD o, UUID avatarID)
  100. {
  101. return true;
  102. }
  103. public bool Enqueue(osUTF8 o, UUID avatarID)
  104. {
  105. return true;
  106. }
  107. public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
  108. {
  109. AddEvent(avatarID, "EnableSimulator", handle);
  110. }
  111. public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath,
  112. ulong regionHandle, int regionSizeX, int regionSizeY)
  113. {
  114. AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
  115. }
  116. public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
  117. uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY)
  118. {
  119. AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
  120. }
  121. public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint,
  122. string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
  123. {
  124. AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
  125. }
  126. public void ChatterboxInvitation(
  127. UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
  128. byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
  129. UUID transactionID, bool fromGroup, byte[] binaryBucket)
  130. {
  131. AddEvent(
  132. toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
  133. timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
  134. }
  135. public void ChatterBoxSessionStartReply(UUID sessionID, string sessionName, int type,
  136. bool voiceEnabled, bool voiceModerated, UUID tmpSessionID,
  137. bool sucess, string error,
  138. UUID toAgent)
  139. {
  140. AddEvent(toAgent, "ChatterBoxSessionStartReply", sessionID, sessionName, type,
  141. voiceEnabled, voiceModerated, tmpSessionID,
  142. sucess, error);
  143. }
  144. public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID toAgent, List<GroupChatListAgentUpdateData> updates)
  145. {
  146. AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, toAgent, updates);
  147. }
  148. public void ChatterBoxForceClose (UUID toAgent, UUID sessionID, string reason)
  149. {
  150. AddEvent(toAgent, "ForceCloseChatterBoxSession", sessionID, reason);
  151. }
  152. public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
  153. {
  154. AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
  155. }
  156. public void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data)
  157. {
  158. AddEvent(receiverAgent, "AgentGroupDataUpdate", data);
  159. }
  160. public void ScriptRunningEvent (UUID objectID, UUID itemID, bool running, UUID avatarID)
  161. {
  162. Console.WriteLine("ONE");
  163. throw new System.NotImplementedException ();
  164. }
  165. public byte[] BuildEvent(string eventName, OSD eventBody)
  166. {
  167. Console.WriteLine("TWOoo");
  168. throw new System.NotImplementedException();
  169. }
  170. public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
  171. {
  172. AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
  173. }
  174. public void WindlightRefreshEvent(int interpolate, UUID avatarID)
  175. {
  176. }
  177. public osUTF8 StartEvent(string eventName)
  178. {
  179. return null;
  180. }
  181. public osUTF8 StartEvent(string eventName, int cap)
  182. {
  183. return null;
  184. }
  185. public byte[] EndEventToBytes(osUTF8 sb)
  186. {
  187. return new byte[0];
  188. }
  189. }
  190. }