aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs')
-rw-r--r--OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs141
1 files changed, 141 insertions, 0 deletions
diff --git a/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs b/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs
new file mode 100644
index 0000000..e23a7d1
--- /dev/null
+++ b/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs
@@ -0,0 +1,141 @@
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 OpenSim 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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using log4net;
33using log4net.Config;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Statistics;
42using OpenSim.Grid.Communications.OGS1;
43using OpenSim.Grid.Framework;
44using OpenSim.Grid.UserServer.Modules;
45
46namespace OpenSim.Grid.UserServer
47{
48 //Do we actually need these event dispatchers?
49 //shouldn't the other modules just directly register event handlers to each other?
50 public class UserServerEventDispatchModule
51 {
52 protected UserManager m_userManager;
53 protected MessageServersConnector m_messagesService;
54 protected UserLoginService m_loginService;
55
56 public UserServerEventDispatchModule(UserManager userManager, MessageServersConnector messagesService, UserLoginService loginService)
57 {
58 m_userManager = userManager;
59 m_messagesService = messagesService;
60 m_loginService = loginService;
61 }
62
63 public void Initialise(IUGAIMCore core)
64 {
65 }
66
67 public void PostInitialise()
68 {
69 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
70 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
71
72 m_messagesService.OnAgentLocation += HandleAgentLocation;
73 m_messagesService.OnAgentLeaving += HandleAgentLeaving;
74 m_messagesService.OnRegionStartup += HandleRegionStartup;
75 m_messagesService.OnRegionShutdown += HandleRegionShutdown;
76 }
77
78 public void RegisterHandlers(BaseHttpServer httpServer)
79 {
80
81 }
82
83 public void Close()
84 {
85 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
86 }
87
88 #region Event Handlers
89 public void NotifyMessageServersUserLoggOff(UUID agentID)
90 {
91 m_messagesService.TellMessageServersAboutUserLogoff(agentID);
92 }
93
94 public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID,
95 ulong regionhandle, float positionX, float positionY,
96 float positionZ, string firstname, string lastname)
97 {
98 m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
99 positionY, positionZ, firstname, lastname);
100 }
101
102 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
103 {
104 m_userManager.HandleAgentLocation(agentID, regionID, regionHandle);
105 }
106
107 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
108 {
109 m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle);
110 }
111
112 public void HandleRegionStartup(UUID regionID)
113 {
114 // This might seem strange, that we send this back to the
115 // server it came from. But there is method to the madness.
116 // There can be multiple user servers on the same database,
117 // and each can have multiple messaging servers. So, we send
118 // it to all known user servers, who send it to all known
119 // message servers. That way, we should be able to finally
120 // update presence to all regions and thereby all friends
121 //
122 m_userManager.HandleRegionStartup(regionID);
123 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
124 }
125
126 public void HandleRegionShutdown(UUID regionID)
127 {
128 // This might seem strange, that we send this back to the
129 // server it came from. But there is method to the madness.
130 // There can be multiple user servers on the same database,
131 // and each can have multiple messaging servers. So, we send
132 // it to all known user servers, who send it to all known
133 // message servers. That way, we should be able to finally
134 // update presence to all regions and thereby all friends
135 //
136 m_userManager.HandleRegionShutdown(regionID);
137 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
138 }
139 #endregion
140 }
141}