diff options
Diffstat (limited to 'OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs')
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs new file mode 100644 index 0000000..f2bae58 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs | |||
@@ -0,0 +1,182 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
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 | |||
45 | namespace OpenSim.Tests.Common | ||
46 | { | ||
47 | public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule | ||
48 | { | ||
49 | public class Event | ||
50 | { | ||
51 | public string Name { get; set; } | ||
52 | public object[] Args { get; set; } | ||
53 | |||
54 | public Event(string name, object[] args) | ||
55 | { | ||
56 | name = Name; | ||
57 | args = Args; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | public Dictionary<UUID, List<Event>> Events { get; set; } | ||
62 | |||
63 | public void Initialise(IConfigSource source) {} | ||
64 | |||
65 | public void Close() {} | ||
66 | |||
67 | public void AddRegion(Scene scene) | ||
68 | { | ||
69 | Events = new Dictionary<UUID, List<Event>>(); | ||
70 | scene.RegisterModuleInterface<IEventQueue>(this); | ||
71 | } | ||
72 | |||
73 | public void RemoveRegion (Scene scene) {} | ||
74 | |||
75 | public void RegionLoaded (Scene scene) {} | ||
76 | |||
77 | public string Name { get { return "TestEventQueueGetModule"; } } | ||
78 | |||
79 | public Type ReplaceableInterface { get { return null; } } | ||
80 | |||
81 | private void AddEvent(UUID avatarID, string name, params object[] args) | ||
82 | { | ||
83 | Console.WriteLine("Adding event {0} for {1}", name, avatarID); | ||
84 | |||
85 | List<Event> avEvents; | ||
86 | |||
87 | if (!Events.ContainsKey(avatarID)) | ||
88 | { | ||
89 | avEvents = new List<Event>(); | ||
90 | Events[avatarID] = avEvents; | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | avEvents = Events[avatarID]; | ||
95 | } | ||
96 | |||
97 | avEvents.Add(new Event(name, args)); | ||
98 | } | ||
99 | |||
100 | public void ClearEvents() | ||
101 | { | ||
102 | if (Events != null) | ||
103 | Events.Clear(); | ||
104 | } | ||
105 | |||
106 | public bool Enqueue(OSD o, UUID avatarID) | ||
107 | { | ||
108 | AddEvent(avatarID, "Enqueue", o); | ||
109 | return true; | ||
110 | } | ||
111 | |||
112 | public void DisableSimulator(ulong handle, UUID avatarID) | ||
113 | { | ||
114 | AddEvent(avatarID, "DisableSimulator", handle); | ||
115 | } | ||
116 | |||
117 | public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) | ||
118 | { | ||
119 | AddEvent(avatarID, "EnableSimulator", handle); | ||
120 | } | ||
121 | |||
122 | public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath, | ||
123 | ulong regionHandle, int regionSizeX, int regionSizeY) | ||
124 | { | ||
125 | AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath); | ||
126 | } | ||
127 | |||
128 | public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | ||
129 | uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY) | ||
130 | { | ||
131 | AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL); | ||
132 | } | ||
133 | |||
134 | public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, | ||
135 | string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) | ||
136 | { | ||
137 | AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID); | ||
138 | } | ||
139 | |||
140 | public void ChatterboxInvitation( | ||
141 | UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName, | ||
142 | byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl, | ||
143 | UUID transactionID, bool fromGroup, byte[] binaryBucket) | ||
144 | { | ||
145 | AddEvent( | ||
146 | toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog, | ||
147 | timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket); | ||
148 | } | ||
149 | |||
150 | public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute) | ||
151 | { | ||
152 | AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute); | ||
153 | } | ||
154 | |||
155 | public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID) | ||
156 | { | ||
157 | AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage); | ||
158 | } | ||
159 | |||
160 | public void GroupMembership (OpenMetaverse.Packets.AgentGroupDataUpdatePacket groupUpdate, UUID avatarID) | ||
161 | { | ||
162 | AddEvent(avatarID, "GroupMembership", groupUpdate); | ||
163 | } | ||
164 | |||
165 | public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono) | ||
166 | { | ||
167 | Console.WriteLine("ONE"); | ||
168 | throw new System.NotImplementedException (); | ||
169 | } | ||
170 | |||
171 | public OSD BuildEvent(string eventName, OSD eventBody) | ||
172 | { | ||
173 | Console.WriteLine("TWO"); | ||
174 | throw new System.NotImplementedException (); | ||
175 | } | ||
176 | |||
177 | public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID) | ||
178 | { | ||
179 | AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod); | ||
180 | } | ||
181 | } | ||
182 | } \ No newline at end of file | ||