diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut')
13 files changed, 1864 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs new file mode 100644 index 0000000..4c65722 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs | |||
@@ -0,0 +1,159 @@ | |||
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.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | ||
41 | { | ||
42 | public class LocalAuthenticationServicesConnector : ISharedRegionModule, IAuthenticationService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private IAuthenticationService m_AuthenticationService; | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | #region ISharedRegionModule | ||
53 | |||
54 | public Type ReplaceableInterface | ||
55 | { | ||
56 | get { return null; } | ||
57 | } | ||
58 | |||
59 | public string Name | ||
60 | { | ||
61 | get { return "LocalAuthenticationServicesConnector"; } | ||
62 | } | ||
63 | |||
64 | public void Initialise(IConfigSource source) | ||
65 | { | ||
66 | IConfig moduleConfig = source.Configs["Modules"]; | ||
67 | if (moduleConfig != null) | ||
68 | { | ||
69 | string name = moduleConfig.GetString("AuthenticationServices", ""); | ||
70 | if (name == Name) | ||
71 | { | ||
72 | IConfig userConfig = source.Configs["AuthenticationService"]; | ||
73 | if (userConfig == null) | ||
74 | { | ||
75 | m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini"); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | string serviceDll = userConfig.GetString("LocalServiceModule", | ||
80 | String.Empty); | ||
81 | |||
82 | if (serviceDll == String.Empty) | ||
83 | { | ||
84 | m_log.Error("[AUTH CONNECTOR]: No LocalServiceModule named in section AuthenticationService"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | Object[] args = new Object[] { source }; | ||
89 | m_AuthenticationService = | ||
90 | ServerUtils.LoadPlugin<IAuthenticationService>(serviceDll, | ||
91 | args); | ||
92 | |||
93 | if (m_AuthenticationService == null) | ||
94 | { | ||
95 | m_log.Error("[AUTH CONNECTOR]: Can't load Authentication service"); | ||
96 | return; | ||
97 | } | ||
98 | m_Enabled = true; | ||
99 | m_log.Info("[AUTH CONNECTOR]: Local Authentication connector enabled"); | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public void PostInitialise() | ||
105 | { | ||
106 | if (!m_Enabled) | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | public void Close() | ||
111 | { | ||
112 | if (!m_Enabled) | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | public void AddRegion(Scene scene) | ||
117 | { | ||
118 | if (!m_Enabled) | ||
119 | return; | ||
120 | |||
121 | scene.RegisterModuleInterface<IAuthenticationService>(m_AuthenticationService); | ||
122 | } | ||
123 | |||
124 | public void RemoveRegion(Scene scene) | ||
125 | { | ||
126 | if (!m_Enabled) | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | public void RegionLoaded(Scene scene) | ||
131 | { | ||
132 | if (!m_Enabled) | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IAuthenticationService | ||
139 | |||
140 | public string Authenticate(UUID principalID, string password, int lifetime) | ||
141 | { | ||
142 | // Not implemented at the regions | ||
143 | return string.Empty; | ||
144 | } | ||
145 | |||
146 | public bool Verify(UUID principalID, string token, int lifetime) | ||
147 | { | ||
148 | return m_AuthenticationService.Verify(principalID, token, lifetime); | ||
149 | } | ||
150 | |||
151 | public bool Release(UUID principalID, string token) | ||
152 | { | ||
153 | return m_AuthenticationService.Release(principalID, token); | ||
154 | } | ||
155 | |||
156 | #endregion | ||
157 | |||
158 | } | ||
159 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs new file mode 100644 index 0000000..a053bc2 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs | |||
@@ -0,0 +1,114 @@ | |||
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 Nini.Config; | ||
30 | using log4net; | ||
31 | using System.Reflection; | ||
32 | using OpenSim.Region.Framework.Interfaces; | ||
33 | using OpenSim.Region.Framework.Scenes; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | |||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | ||
38 | { | ||
39 | public class RemoteAuthenticationServicesConnector : AuthenticationServicesConnector, | ||
40 | ISharedRegionModule, IAuthenticationService | ||
41 | { | ||
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger( | ||
44 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private bool m_Enabled = false; | ||
47 | |||
48 | public Type ReplaceableInterface | ||
49 | { | ||
50 | get { return null; } | ||
51 | } | ||
52 | |||
53 | public string Name | ||
54 | { | ||
55 | get { return "RemoteAuthenticationServicesConnector"; } | ||
56 | } | ||
57 | |||
58 | public override void Initialise(IConfigSource source) | ||
59 | { | ||
60 | IConfig moduleConfig = source.Configs["Modules"]; | ||
61 | if (moduleConfig != null) | ||
62 | { | ||
63 | string name = moduleConfig.GetString("AuthenticationServices", ""); | ||
64 | if (name == Name) | ||
65 | { | ||
66 | IConfig userConfig = source.Configs["AuthenticationService"]; | ||
67 | if (userConfig == null) | ||
68 | { | ||
69 | m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini"); | ||
70 | return; | ||
71 | } | ||
72 | |||
73 | m_Enabled = true; | ||
74 | |||
75 | base.Initialise(source); | ||
76 | |||
77 | m_log.Info("[AUTH CONNECTOR]: Remote Authentication enabled"); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public void PostInitialise() | ||
83 | { | ||
84 | if (!m_Enabled) | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | public void Close() | ||
89 | { | ||
90 | if (!m_Enabled) | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | public void AddRegion(Scene scene) | ||
95 | { | ||
96 | if (!m_Enabled) | ||
97 | return; | ||
98 | |||
99 | scene.RegisterModuleInterface<IAuthenticationService>(this); | ||
100 | } | ||
101 | |||
102 | public void RemoveRegion(Scene scene) | ||
103 | { | ||
104 | if (!m_Enabled) | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | public void RegionLoaded(Scene scene) | ||
109 | { | ||
110 | if (!m_Enabled) | ||
111 | return; | ||
112 | } | ||
113 | } | ||
114 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs new file mode 100644 index 0000000..0c8ee61 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs | |||
@@ -0,0 +1,168 @@ | |||
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.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar | ||
41 | { | ||
42 | public class LocalAvatarServicesConnector : ISharedRegionModule, IAvatarService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private IAvatarService m_AvatarService; | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | #region ISharedRegionModule | ||
53 | |||
54 | public Type ReplaceableInterface | ||
55 | { | ||
56 | get { return null; } | ||
57 | } | ||
58 | |||
59 | public string Name | ||
60 | { | ||
61 | get { return "LocalAvatarServicesConnector"; } | ||
62 | } | ||
63 | |||
64 | public void Initialise(IConfigSource source) | ||
65 | { | ||
66 | IConfig moduleConfig = source.Configs["Modules"]; | ||
67 | if (moduleConfig != null) | ||
68 | { | ||
69 | string name = moduleConfig.GetString("AvatarServices", ""); | ||
70 | if (name == Name) | ||
71 | { | ||
72 | IConfig userConfig = source.Configs["AvatarService"]; | ||
73 | if (userConfig == null) | ||
74 | { | ||
75 | m_log.Error("[USER CONNECTOR]: AvatarService missing from OpenSim.ini"); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | string serviceDll = userConfig.GetString("LocalServiceModule", | ||
80 | String.Empty); | ||
81 | |||
82 | if (serviceDll == String.Empty) | ||
83 | { | ||
84 | m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section AvatarService"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | Object[] args = new Object[] { source }; | ||
89 | m_AvatarService = | ||
90 | ServerUtils.LoadPlugin<IAvatarService>(serviceDll, | ||
91 | args); | ||
92 | |||
93 | if (m_AvatarService == null) | ||
94 | { | ||
95 | m_log.Error("[USER CONNECTOR]: Can't load user account service"); | ||
96 | return; | ||
97 | } | ||
98 | m_Enabled = true; | ||
99 | m_log.Info("[USER CONNECTOR]: Local avatar connector enabled"); | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public void PostInitialise() | ||
105 | { | ||
106 | if (!m_Enabled) | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | public void Close() | ||
111 | { | ||
112 | if (!m_Enabled) | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | public void AddRegion(Scene scene) | ||
117 | { | ||
118 | if (!m_Enabled) | ||
119 | return; | ||
120 | |||
121 | scene.RegisterModuleInterface<IAvatarService>(m_AvatarService); | ||
122 | } | ||
123 | |||
124 | public void RemoveRegion(Scene scene) | ||
125 | { | ||
126 | if (!m_Enabled) | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | public void RegionLoaded(Scene scene) | ||
131 | { | ||
132 | if (!m_Enabled) | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IAvatarService | ||
139 | |||
140 | public AvatarData GetAvatar(UUID userID) | ||
141 | { | ||
142 | return m_AvatarService.GetAvatar(userID); | ||
143 | } | ||
144 | |||
145 | public bool SetAvatar(UUID userID, AvatarData avatar) | ||
146 | { | ||
147 | return m_AvatarService.SetAvatar(userID, avatar); | ||
148 | } | ||
149 | |||
150 | public bool ResetAvatar(UUID userID) | ||
151 | { | ||
152 | return m_AvatarService.ResetAvatar(userID); | ||
153 | } | ||
154 | |||
155 | public bool SetItems(UUID userID, string[] names, string[] values) | ||
156 | { | ||
157 | return m_AvatarService.SetItems(userID, names, values); | ||
158 | } | ||
159 | |||
160 | public bool RemoveItems(UUID userID, string[] names) | ||
161 | { | ||
162 | return m_AvatarService.RemoveItems(userID, names); | ||
163 | } | ||
164 | |||
165 | #endregion | ||
166 | |||
167 | } | ||
168 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs new file mode 100644 index 0000000..48759b5 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs | |||
@@ -0,0 +1,114 @@ | |||
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 Nini.Config; | ||
30 | using log4net; | ||
31 | using System.Reflection; | ||
32 | using OpenSim.Region.Framework.Interfaces; | ||
33 | using OpenSim.Region.Framework.Scenes; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | |||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar | ||
38 | { | ||
39 | public class RemoteAvatarServicesConnector : AvatarServicesConnector, | ||
40 | ISharedRegionModule, IAvatarService | ||
41 | { | ||
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger( | ||
44 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private bool m_Enabled = false; | ||
47 | |||
48 | public Type ReplaceableInterface | ||
49 | { | ||
50 | get { return null; } | ||
51 | } | ||
52 | |||
53 | public string Name | ||
54 | { | ||
55 | get { return "RemoteAvatarServicesConnector"; } | ||
56 | } | ||
57 | |||
58 | public override void Initialise(IConfigSource source) | ||
59 | { | ||
60 | IConfig moduleConfig = source.Configs["Modules"]; | ||
61 | if (moduleConfig != null) | ||
62 | { | ||
63 | string name = moduleConfig.GetString("AvatarServices", ""); | ||
64 | if (name == Name) | ||
65 | { | ||
66 | IConfig userConfig = source.Configs["AvatarService"]; | ||
67 | if (userConfig == null) | ||
68 | { | ||
69 | m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpanSim.ini"); | ||
70 | return; | ||
71 | } | ||
72 | |||
73 | m_Enabled = true; | ||
74 | |||
75 | base.Initialise(source); | ||
76 | |||
77 | m_log.Info("[AVATAR CONNECTOR]: Remote avatars enabled"); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public void PostInitialise() | ||
83 | { | ||
84 | if (!m_Enabled) | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | public void Close() | ||
89 | { | ||
90 | if (!m_Enabled) | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | public void AddRegion(Scene scene) | ||
95 | { | ||
96 | if (!m_Enabled) | ||
97 | return; | ||
98 | |||
99 | scene.RegisterModuleInterface<IAvatarService>(this); | ||
100 | } | ||
101 | |||
102 | public void RemoveRegion(Scene scene) | ||
103 | { | ||
104 | if (!m_Enabled) | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | public void RegionLoaded(Scene scene) | ||
109 | { | ||
110 | if (!m_Enabled) | ||
111 | return; | ||
112 | } | ||
113 | } | ||
114 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 44458d1..fa3681a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs | |||
@@ -436,12 +436,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
436 | } | 436 | } |
437 | 437 | ||
438 | OSDMap resp = new OSDMap(2); | 438 | OSDMap resp = new OSDMap(2); |
439 | string reason = String.Empty; | 439 | string reason = String.Empty; |
440 | uint teleportFlags = 0; | 440 | uint teleportFlags = 0; |
441 | if (args.ContainsKey("teleport_flags")) | 441 | if (args.ContainsKey("teleport_flags")) |
442 | { | 442 | { |
443 | teleportFlags = args["teleport_flags"].AsUInteger(); | 443 | teleportFlags = args["teleport_flags"].AsUInteger(); |
444 | } | 444 | } |
445 | 445 | ||
446 | // This is the meaning of POST agent | 446 | // This is the meaning of POST agent |
447 | m_regionClient.AdjustUserInformation(aCircuit); | 447 | m_regionClient.AdjustUserInformation(aCircuit); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs new file mode 100644 index 0000000..2cb18c7 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | |||
@@ -0,0 +1,200 @@ | |||
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.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Region.Framework.Interfaces; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Server.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using log4net; | ||
39 | using Nini.Config; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
42 | { | ||
43 | public class LocalPresenceServicesConnector : ISharedRegionModule, IPresenceService | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private bool m_Enabled = false; | ||
48 | |||
49 | private PresenceDetector m_PresenceDetector; | ||
50 | private IPresenceService m_PresenceService; | ||
51 | |||
52 | public LocalPresenceServicesConnector() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public LocalPresenceServicesConnector(IConfigSource source) | ||
57 | { | ||
58 | Initialise(source); | ||
59 | } | ||
60 | |||
61 | #region ISharedRegionModule | ||
62 | |||
63 | public Type ReplaceableInterface | ||
64 | { | ||
65 | get { return null; } | ||
66 | } | ||
67 | |||
68 | public string Name | ||
69 | { | ||
70 | get { return "LocalPresenceServicesConnector"; } | ||
71 | } | ||
72 | |||
73 | public void Initialise(IConfigSource source) | ||
74 | { | ||
75 | IConfig moduleConfig = source.Configs["Modules"]; | ||
76 | if (moduleConfig != null) | ||
77 | { | ||
78 | string name = moduleConfig.GetString("PresenceServices", ""); | ||
79 | if (name == Name) | ||
80 | { | ||
81 | IConfig inventoryConfig = source.Configs["PresenceService"]; | ||
82 | if (inventoryConfig == null) | ||
83 | { | ||
84 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | string serviceDll = inventoryConfig.GetString("LocalServiceModule", String.Empty); | ||
89 | |||
90 | if (serviceDll == String.Empty) | ||
91 | { | ||
92 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: No LocalServiceModule named in section PresenceService"); | ||
93 | return; | ||
94 | } | ||
95 | |||
96 | Object[] args = new Object[] { source }; | ||
97 | m_log.DebugFormat("[LOCAL PRESENCE CONNECTOR]: Service dll = {0}", serviceDll); | ||
98 | |||
99 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(serviceDll, args); | ||
100 | |||
101 | if (m_PresenceService == null) | ||
102 | { | ||
103 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: Can't load presence service"); | ||
104 | //return; | ||
105 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | ||
106 | } | ||
107 | |||
108 | //Init(source); | ||
109 | |||
110 | m_PresenceDetector = new PresenceDetector(this); | ||
111 | |||
112 | m_Enabled = true; | ||
113 | m_log.Info("[LOCAL PRESENCE CONNECTOR]: Local presence connector enabled"); | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | |||
118 | public void PostInitialise() | ||
119 | { | ||
120 | } | ||
121 | |||
122 | public void Close() | ||
123 | { | ||
124 | } | ||
125 | |||
126 | public void AddRegion(Scene scene) | ||
127 | { | ||
128 | if (!m_Enabled) | ||
129 | return; | ||
130 | |||
131 | // m_log.DebugFormat( | ||
132 | // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); | ||
133 | |||
134 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
135 | m_PresenceDetector.AddRegion(scene); | ||
136 | |||
137 | m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName); | ||
138 | |||
139 | } | ||
140 | |||
141 | public void RemoveRegion(Scene scene) | ||
142 | { | ||
143 | if (!m_Enabled) | ||
144 | return; | ||
145 | |||
146 | m_PresenceDetector.RemoveRegion(scene); | ||
147 | } | ||
148 | |||
149 | public void RegionLoaded(Scene scene) | ||
150 | { | ||
151 | if (!m_Enabled) | ||
152 | return; | ||
153 | |||
154 | } | ||
155 | |||
156 | #endregion | ||
157 | |||
158 | #region IPresenceService | ||
159 | |||
160 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
161 | { | ||
162 | m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
163 | return false; | ||
164 | } | ||
165 | |||
166 | public bool LogoutAgent(UUID sessionID) | ||
167 | { | ||
168 | return m_PresenceService.LogoutAgent(sessionID); | ||
169 | } | ||
170 | |||
171 | |||
172 | public bool LogoutRegionAgents(UUID regionID) | ||
173 | { | ||
174 | return m_PresenceService.LogoutRegionAgents(regionID); | ||
175 | } | ||
176 | |||
177 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
178 | { | ||
179 | return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt); | ||
180 | } | ||
181 | |||
182 | public PresenceInfo GetAgent(UUID sessionID) | ||
183 | { | ||
184 | return m_PresenceService.GetAgent(sessionID); | ||
185 | } | ||
186 | |||
187 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
188 | { | ||
189 | return m_PresenceService.GetAgents(userIDs); | ||
190 | } | ||
191 | |||
192 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
193 | { | ||
194 | return m_PresenceService.SetHomeLocation(userID, regionID, position, lookAt); | ||
195 | } | ||
196 | |||
197 | #endregion | ||
198 | |||
199 | } | ||
200 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs new file mode 100644 index 0000000..3ca5560 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | |||
@@ -0,0 +1,84 @@ | |||
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.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
39 | { | ||
40 | public class PresenceDetector | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | private IPresenceService m_PresenceService; | ||
45 | |||
46 | public PresenceDetector(IPresenceService presenceservice) | ||
47 | { | ||
48 | m_PresenceService = presenceservice; | ||
49 | } | ||
50 | |||
51 | public void AddRegion(Scene scene) | ||
52 | { | ||
53 | scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; | ||
54 | scene.EventManager.OnNewClient += OnNewClient; | ||
55 | |||
56 | m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); | ||
57 | } | ||
58 | |||
59 | public void RemoveRegion(Scene scene) | ||
60 | { | ||
61 | scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent; | ||
62 | scene.EventManager.OnNewClient -= OnNewClient; | ||
63 | |||
64 | m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); | ||
65 | } | ||
66 | |||
67 | public void OnMakeRootAgent(ScenePresence sp) | ||
68 | { | ||
69 | m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); | ||
70 | m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | ||
71 | } | ||
72 | |||
73 | public void OnNewClient(IClientAPI client) | ||
74 | { | ||
75 | client.OnLogout += OnLogout; | ||
76 | } | ||
77 | |||
78 | public void OnLogout(IClientAPI client) | ||
79 | { | ||
80 | client.OnLogout -= OnLogout; | ||
81 | m_PresenceService.LogoutAgent(client.SessionId); | ||
82 | } | ||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs new file mode 100644 index 0000000..e8e140a --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | |||
@@ -0,0 +1,164 @@ | |||
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.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Region.Framework.Interfaces; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Server.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | using log4net; | ||
40 | using Nini.Config; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
43 | { | ||
44 | public class RemotePresenceServicesConnector : ISharedRegionModule, IPresenceService | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | #region ISharedRegionModule | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | private PresenceDetector m_PresenceDetector; | ||
53 | private IPresenceService m_RemoteConnector; | ||
54 | |||
55 | public Type ReplaceableInterface | ||
56 | { | ||
57 | get { return null; } | ||
58 | } | ||
59 | |||
60 | public string Name | ||
61 | { | ||
62 | get { return "RemotePresenceServiceConnector"; } | ||
63 | } | ||
64 | |||
65 | public void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig moduleConfig = source.Configs["Modules"]; | ||
68 | if (moduleConfig != null) | ||
69 | { | ||
70 | string name = moduleConfig.GetString("PresenceServices", ""); | ||
71 | if (name == Name) | ||
72 | { | ||
73 | m_RemoteConnector = new PresenceServicesConnector(source); | ||
74 | |||
75 | m_Enabled = true; | ||
76 | |||
77 | m_PresenceDetector = new PresenceDetector(this); | ||
78 | |||
79 | m_log.Info("[INVENTORY CONNECTOR]: Remote presence enabled"); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | } | ||
84 | |||
85 | public void PostInitialise() | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public void Close() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_Enabled) | ||
96 | return; | ||
97 | |||
98 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
99 | m_PresenceDetector.AddRegion(scene); | ||
100 | |||
101 | m_log.InfoFormat("[REMOTE PRESENCE CONNECTOR]: Enabled remote presence for region {0}", scene.RegionInfo.RegionName); | ||
102 | |||
103 | } | ||
104 | |||
105 | public void RemoveRegion(Scene scene) | ||
106 | { | ||
107 | if (!m_Enabled) | ||
108 | return; | ||
109 | |||
110 | m_PresenceDetector.RemoveRegion(scene); | ||
111 | } | ||
112 | |||
113 | public void RegionLoaded(Scene scene) | ||
114 | { | ||
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | } | ||
119 | |||
120 | #endregion | ||
121 | |||
122 | #region IPresenceService | ||
123 | |||
124 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
125 | { | ||
126 | m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
127 | return false; | ||
128 | } | ||
129 | |||
130 | public bool LogoutAgent(UUID sessionID) | ||
131 | { | ||
132 | return m_RemoteConnector.LogoutAgent(sessionID); | ||
133 | } | ||
134 | |||
135 | |||
136 | public bool LogoutRegionAgents(UUID regionID) | ||
137 | { | ||
138 | return m_RemoteConnector.LogoutRegionAgents(regionID); | ||
139 | } | ||
140 | |||
141 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
142 | { | ||
143 | return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt); | ||
144 | } | ||
145 | |||
146 | public PresenceInfo GetAgent(UUID sessionID) | ||
147 | { | ||
148 | return m_RemoteConnector.GetAgent(sessionID); | ||
149 | } | ||
150 | |||
151 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
152 | { | ||
153 | return m_RemoteConnector.GetAgents(userIDs); | ||
154 | } | ||
155 | |||
156 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
157 | { | ||
158 | return m_RemoteConnector.SetHomeLocation(userID, regionID, position, lookAt); | ||
159 | } | ||
160 | |||
161 | #endregion | ||
162 | |||
163 | } | ||
164 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs new file mode 100644 index 0000000..ebb2c3e --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | |||
@@ -0,0 +1,104 @@ | |||
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.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net.Config; | ||
34 | using NUnit.Framework; | ||
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using Nini.Config; | ||
39 | |||
40 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
43 | using OpenSim.Tests.Common; | ||
44 | using OpenSim.Tests.Common.Setup; | ||
45 | |||
46 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | ||
47 | { | ||
48 | [TestFixture] | ||
49 | public class PresenceConnectorsTests | ||
50 | { | ||
51 | LocalPresenceServicesConnector m_LocalConnector; | ||
52 | private void SetUp() | ||
53 | { | ||
54 | IConfigSource config = new IniConfigSource(); | ||
55 | config.AddConfig("Modules"); | ||
56 | config.AddConfig("PresenceService"); | ||
57 | config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); | ||
58 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | ||
59 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullPresenceData"); | ||
60 | |||
61 | m_LocalConnector = new LocalPresenceServicesConnector(config); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Test OpenSim Presence. | ||
66 | /// </summary> | ||
67 | [Test] | ||
68 | public void TestPresenceV0_1() | ||
69 | { | ||
70 | SetUp(); | ||
71 | |||
72 | string user1 = UUID.Zero.ToString(); | ||
73 | UUID session1 = UUID.Zero; | ||
74 | |||
75 | // this is not implemented by this connector | ||
76 | //m_LocalConnector.LoginAgent(user1, session1, UUID.Zero); | ||
77 | PresenceInfo result = m_LocalConnector.GetAgent(session1); | ||
78 | Assert.IsNotNull(result, "Retrieved GetAgent is null"); | ||
79 | Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match"); | ||
80 | Assert.IsTrue(result.Online, "Agent just logged in but is offline"); | ||
81 | |||
82 | UUID region1 = UUID.Random(); | ||
83 | bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); | ||
84 | Assert.IsTrue(r, "First ReportAgent returned false"); | ||
85 | result = m_LocalConnector.GetAgent(session1); | ||
86 | Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)"); | ||
87 | |||
88 | UUID region2 = UUID.Random(); | ||
89 | r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero); | ||
90 | Assert.IsTrue(r, "Second ReportAgent returned false"); | ||
91 | result = m_LocalConnector.GetAgent(session1); | ||
92 | Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)"); | ||
93 | |||
94 | r = m_LocalConnector.LogoutAgent(session1); | ||
95 | Assert.IsTrue(r, "LogoutAgent returned false"); | ||
96 | result = m_LocalConnector.GetAgent(session1); | ||
97 | Assert.IsNotNull(result, "Agent session disappeared from storage after logout"); | ||
98 | Assert.IsFalse(result.Online, "Agent is reported to be Online after logout"); | ||
99 | |||
100 | r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); | ||
101 | Assert.IsFalse(r, "ReportAgent of non-logged in user returned true"); | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs new file mode 100644 index 0000000..074bfb5 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -0,0 +1,339 @@ | |||
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.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using Nini.Config; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | |||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | ||
40 | { | ||
41 | public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | private List<Scene> m_sceneList = new List<Scene>(); | ||
45 | |||
46 | private bool m_ModuleEnabled = false; | ||
47 | |||
48 | #region IRegionModule | ||
49 | |||
50 | public void Initialise(IConfigSource config) | ||
51 | { | ||
52 | IConfig moduleConfig = config.Configs["Modules"]; | ||
53 | if (moduleConfig != null) | ||
54 | { | ||
55 | string name = moduleConfig.GetString("SimulationServices", ""); | ||
56 | if (name == Name) | ||
57 | { | ||
58 | //IConfig userConfig = config.Configs["SimulationService"]; | ||
59 | //if (userConfig == null) | ||
60 | //{ | ||
61 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
62 | // return; | ||
63 | //} | ||
64 | |||
65 | m_ModuleEnabled = true; | ||
66 | |||
67 | m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled"); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | public void PostInitialise() | ||
73 | { | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene scene) | ||
77 | { | ||
78 | if (!m_ModuleEnabled) | ||
79 | return; | ||
80 | |||
81 | Init(scene); | ||
82 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
83 | } | ||
84 | |||
85 | public void RemoveRegion(Scene scene) | ||
86 | { | ||
87 | if (!m_ModuleEnabled) | ||
88 | return; | ||
89 | |||
90 | RemoveScene(scene); | ||
91 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
92 | } | ||
93 | |||
94 | public void RegionLoaded(Scene scene) | ||
95 | { | ||
96 | } | ||
97 | |||
98 | public void Close() | ||
99 | { | ||
100 | } | ||
101 | |||
102 | public Type ReplaceableInterface | ||
103 | { | ||
104 | get { return null; } | ||
105 | } | ||
106 | |||
107 | public string Name | ||
108 | { | ||
109 | get { return "LocalSimulationConnectorModule"; } | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
113 | /// Can be called from other modules. | ||
114 | /// </summary> | ||
115 | /// <param name="scene"></param> | ||
116 | public void RemoveScene(Scene scene) | ||
117 | { | ||
118 | lock (m_sceneList) | ||
119 | { | ||
120 | if (m_sceneList.Contains(scene)) | ||
121 | { | ||
122 | m_sceneList.Remove(scene); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Can be called from other modules. | ||
129 | /// </summary> | ||
130 | /// <param name="scene"></param> | ||
131 | public void Init(Scene scene) | ||
132 | { | ||
133 | if (!m_sceneList.Contains(scene)) | ||
134 | { | ||
135 | lock (m_sceneList) | ||
136 | { | ||
137 | m_sceneList.Add(scene); | ||
138 | } | ||
139 | |||
140 | } | ||
141 | } | ||
142 | |||
143 | #endregion /* IRegionModule */ | ||
144 | |||
145 | #region ISimulation | ||
146 | |||
147 | public IScene GetScene(ulong regionhandle) | ||
148 | { | ||
149 | foreach (Scene s in m_sceneList) | ||
150 | { | ||
151 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
152 | return s; | ||
153 | } | ||
154 | // ? weird. should not happen | ||
155 | return m_sceneList[0]; | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * Agent-related communications | ||
160 | */ | ||
161 | |||
162 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
163 | { | ||
164 | if (destination == null) | ||
165 | { | ||
166 | reason = "Given destination was null"; | ||
167 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
168 | return false; | ||
169 | } | ||
170 | |||
171 | foreach (Scene s in m_sceneList) | ||
172 | { | ||
173 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
174 | { | ||
175 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); | ||
176 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); | ||
181 | reason = "Did not find region " + destination.RegionName; | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) | ||
186 | { | ||
187 | if (destination == null) | ||
188 | return false; | ||
189 | |||
190 | foreach (Scene s in m_sceneList) | ||
191 | { | ||
192 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
193 | { | ||
194 | //m_log.DebugFormat( | ||
195 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", | ||
196 | // s.RegionInfo.RegionName, regionHandle); | ||
197 | |||
198 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
199 | return true; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); | ||
204 | return false; | ||
205 | } | ||
206 | |||
207 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) | ||
208 | { | ||
209 | if (destination == null) | ||
210 | return false; | ||
211 | |||
212 | foreach (Scene s in m_sceneList) | ||
213 | { | ||
214 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
215 | { | ||
216 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
217 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
222 | return false; | ||
223 | } | ||
224 | |||
225 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
226 | { | ||
227 | agent = null; | ||
228 | |||
229 | if (destination == null) | ||
230 | return false; | ||
231 | |||
232 | foreach (Scene s in m_sceneList) | ||
233 | { | ||
234 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
235 | { | ||
236 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
237 | return s.IncomingRetrieveRootAgent(id, out agent); | ||
238 | } | ||
239 | } | ||
240 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
241 | return false; | ||
242 | } | ||
243 | |||
244 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) | ||
245 | { | ||
246 | if (destination == null) | ||
247 | return false; | ||
248 | |||
249 | foreach (Scene s in m_sceneList) | ||
250 | { | ||
251 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
252 | { | ||
253 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | ||
254 | return s.IncomingReleaseAgent(id); | ||
255 | } | ||
256 | } | ||
257 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); | ||
258 | return false; | ||
259 | } | ||
260 | |||
261 | public bool CloseAgent(GridRegion destination, UUID id) | ||
262 | { | ||
263 | if (destination == null) | ||
264 | return false; | ||
265 | |||
266 | foreach (Scene s in m_sceneList) | ||
267 | { | ||
268 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
269 | { | ||
270 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | ||
271 | return s.IncomingCloseAgent(id); | ||
272 | } | ||
273 | } | ||
274 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | ||
275 | return false; | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * Object-related communications | ||
280 | */ | ||
281 | |||
282 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | ||
283 | { | ||
284 | if (destination == null) | ||
285 | return false; | ||
286 | |||
287 | foreach (Scene s in m_sceneList) | ||
288 | { | ||
289 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
290 | { | ||
291 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | ||
292 | if (isLocalCall) | ||
293 | { | ||
294 | // We need to make a local copy of the object | ||
295 | ISceneObject sogClone = sog.CloneForNewScene(); | ||
296 | sogClone.SetState(sog.GetStateSnapshot(), s); | ||
297 | return s.IncomingCreateObject(sogClone); | ||
298 | } | ||
299 | else | ||
300 | { | ||
301 | // Use the object as it came through the wire | ||
302 | return s.IncomingCreateObject(sog); | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | return false; | ||
307 | } | ||
308 | |||
309 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) | ||
310 | { | ||
311 | if (destination == null) | ||
312 | return false; | ||
313 | |||
314 | foreach (Scene s in m_sceneList) | ||
315 | { | ||
316 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
317 | { | ||
318 | return s.IncomingCreateObject(userID, itemID); | ||
319 | } | ||
320 | } | ||
321 | return false; | ||
322 | } | ||
323 | |||
324 | |||
325 | #endregion /* IInterregionComms */ | ||
326 | |||
327 | #region Misc | ||
328 | |||
329 | public bool IsLocalRegion(ulong regionhandle) | ||
330 | { | ||
331 | foreach (Scene s in m_sceneList) | ||
332 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
333 | return true; | ||
334 | return false; | ||
335 | } | ||
336 | |||
337 | #endregion | ||
338 | } | ||
339 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs new file mode 100644 index 0000000..c9cc368 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -0,0 +1,360 @@ | |||
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.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Framework.Communications.Clients; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Services.Connectors.Simulation; | ||
47 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | ||
50 | { | ||
51 | public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService | ||
52 | { | ||
53 | private bool initialized = false; | ||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
56 | protected bool m_enabled = false; | ||
57 | protected Scene m_aScene; | ||
58 | // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module | ||
59 | protected LocalSimulationConnectorModule m_localBackend; | ||
60 | protected SimulationServiceConnector m_remoteConnector; | ||
61 | |||
62 | protected CommunicationsManager m_commsManager; | ||
63 | |||
64 | protected IHyperlinkService m_hyperlinkService; | ||
65 | |||
66 | protected bool m_safemode; | ||
67 | protected IPAddress m_thisIP; | ||
68 | |||
69 | #region IRegionModule | ||
70 | |||
71 | public virtual void Initialise(IConfigSource config) | ||
72 | { | ||
73 | |||
74 | IConfig moduleConfig = config.Configs["Modules"]; | ||
75 | if (moduleConfig != null) | ||
76 | { | ||
77 | string name = moduleConfig.GetString("SimulationServices", ""); | ||
78 | if (name == Name) | ||
79 | { | ||
80 | //IConfig userConfig = config.Configs["SimulationService"]; | ||
81 | //if (userConfig == null) | ||
82 | //{ | ||
83 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
84 | // return; | ||
85 | //} | ||
86 | |||
87 | m_remoteConnector = new SimulationServiceConnector(); | ||
88 | |||
89 | m_enabled = true; | ||
90 | |||
91 | m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled"); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public virtual void PostInitialise() | ||
97 | { | ||
98 | } | ||
99 | |||
100 | public virtual void Close() | ||
101 | { | ||
102 | } | ||
103 | |||
104 | public void AddRegion(Scene scene) | ||
105 | { | ||
106 | if (!m_enabled) | ||
107 | return; | ||
108 | |||
109 | if (!initialized) | ||
110 | { | ||
111 | InitOnce(scene); | ||
112 | initialized = true; | ||
113 | } | ||
114 | InitEach(scene); | ||
115 | } | ||
116 | |||
117 | public void RemoveRegion(Scene scene) | ||
118 | { | ||
119 | if (m_enabled) | ||
120 | { | ||
121 | m_localBackend.RemoveScene(scene); | ||
122 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | public void RegionLoaded(Scene scene) | ||
127 | { | ||
128 | if (!m_enabled) | ||
129 | return; | ||
130 | |||
131 | m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>(); | ||
132 | |||
133 | } | ||
134 | |||
135 | public Type ReplaceableInterface | ||
136 | { | ||
137 | get { return null; } | ||
138 | } | ||
139 | |||
140 | public virtual string Name | ||
141 | { | ||
142 | get { return "RemoteSimulationConnectorModule"; } | ||
143 | } | ||
144 | |||
145 | protected virtual void InitEach(Scene scene) | ||
146 | { | ||
147 | m_localBackend.Init(scene); | ||
148 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
149 | } | ||
150 | |||
151 | protected virtual void InitOnce(Scene scene) | ||
152 | { | ||
153 | m_localBackend = new LocalSimulationConnectorModule(); | ||
154 | m_commsManager = scene.CommsManager; | ||
155 | m_aScene = scene; | ||
156 | //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); | ||
157 | m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); | ||
158 | } | ||
159 | |||
160 | #endregion /* IRegionModule */ | ||
161 | |||
162 | #region IInterregionComms | ||
163 | |||
164 | public IScene GetScene(ulong handle) | ||
165 | { | ||
166 | return m_localBackend.GetScene(handle); | ||
167 | } | ||
168 | |||
169 | /** | ||
170 | * Agent-related communications | ||
171 | */ | ||
172 | |||
173 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
174 | { | ||
175 | if (destination == null) | ||
176 | { | ||
177 | reason = "Given destination was null"; | ||
178 | m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
179 | return false; | ||
180 | } | ||
181 | |||
182 | // Try local first | ||
183 | if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, out reason)) | ||
184 | return true; | ||
185 | |||
186 | // else do the remote thing | ||
187 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
188 | { | ||
189 | //m_regionClient.SendUserInformation(regInfo, aCircuit); | ||
190 | return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason); | ||
191 | } | ||
192 | return false; | ||
193 | } | ||
194 | |||
195 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) | ||
196 | { | ||
197 | if (destination == null) | ||
198 | return false; | ||
199 | |||
200 | // Try local first | ||
201 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | ||
202 | return true; | ||
203 | |||
204 | // else do the remote thing | ||
205 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
206 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
207 | |||
208 | return false; | ||
209 | |||
210 | } | ||
211 | |||
212 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) | ||
213 | { | ||
214 | if (destination == null) | ||
215 | return false; | ||
216 | |||
217 | // Try local first | ||
218 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | ||
219 | return true; | ||
220 | |||
221 | // else do the remote thing | ||
222 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
223 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
224 | |||
225 | return false; | ||
226 | |||
227 | } | ||
228 | |||
229 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
230 | { | ||
231 | agent = null; | ||
232 | |||
233 | if (destination == null) | ||
234 | return false; | ||
235 | |||
236 | // Try local first | ||
237 | if (m_localBackend.RetrieveAgent(destination, id, out agent)) | ||
238 | return true; | ||
239 | |||
240 | // else do the remote thing | ||
241 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
242 | return m_remoteConnector.RetrieveAgent(destination, id, out agent); | ||
243 | |||
244 | return false; | ||
245 | |||
246 | } | ||
247 | |||
248 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) | ||
249 | { | ||
250 | if (destination == null) | ||
251 | return false; | ||
252 | |||
253 | // Try local first | ||
254 | if (m_localBackend.ReleaseAgent(destination, id, uri)) | ||
255 | return true; | ||
256 | |||
257 | // else do the remote thing | ||
258 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
259 | return m_remoteConnector.ReleaseAgent(destination, id, uri); | ||
260 | |||
261 | return false; | ||
262 | } | ||
263 | |||
264 | |||
265 | public bool CloseAgent(GridRegion destination, UUID id) | ||
266 | { | ||
267 | if (destination == null) | ||
268 | return false; | ||
269 | |||
270 | // Try local first | ||
271 | if (m_localBackend.CloseAgent(destination, id)) | ||
272 | return true; | ||
273 | |||
274 | // else do the remote thing | ||
275 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
276 | return m_remoteConnector.CloseAgent(destination, id); | ||
277 | |||
278 | return false; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * Object-related communications | ||
283 | */ | ||
284 | |||
285 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | ||
286 | { | ||
287 | if (destination == null) | ||
288 | return false; | ||
289 | |||
290 | // Try local first | ||
291 | if (m_localBackend.CreateObject(destination, sog, true)) | ||
292 | { | ||
293 | //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); | ||
294 | return true; | ||
295 | } | ||
296 | |||
297 | // else do the remote thing | ||
298 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
299 | return m_remoteConnector.CreateObject(destination, sog, isLocalCall); | ||
300 | |||
301 | return false; | ||
302 | } | ||
303 | |||
304 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) | ||
305 | { | ||
306 | // Not Implemented | ||
307 | return false; | ||
308 | } | ||
309 | |||
310 | #endregion /* IInterregionComms */ | ||
311 | |||
312 | |||
313 | protected class RegionToRegionClient : RegionClient | ||
314 | { | ||
315 | Scene m_aScene = null; | ||
316 | IHyperlinkService m_hyperlinkService; | ||
317 | |||
318 | public RegionToRegionClient(Scene s, IHyperlinkService hyperService) | ||
319 | { | ||
320 | m_aScene = s; | ||
321 | m_hyperlinkService = hyperService; | ||
322 | } | ||
323 | |||
324 | public override ulong GetRegionHandle(ulong handle) | ||
325 | { | ||
326 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
327 | { | ||
328 | if (m_hyperlinkService != null) | ||
329 | return m_hyperlinkService.FindRegionHandle(handle); | ||
330 | } | ||
331 | |||
332 | return handle; | ||
333 | } | ||
334 | |||
335 | public override bool IsHyperlink(ulong handle) | ||
336 | { | ||
337 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
338 | { | ||
339 | if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) | ||
340 | return true; | ||
341 | } | ||
342 | return false; | ||
343 | } | ||
344 | |||
345 | public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) | ||
346 | { | ||
347 | if (m_hyperlinkService != null) | ||
348 | m_hyperlinkService.SendUserInformation(regInfo, aCircuit); | ||
349 | |||
350 | } | ||
351 | |||
352 | public override void AdjustUserInformation(AgentCircuitData aCircuit) | ||
353 | { | ||
354 | if (m_hyperlinkService != null) | ||
355 | m_hyperlinkService.AdjustUserInformation(aCircuit); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | } | ||
360 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index cca5bb4..f55de5a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
31 | using Nini.Config; | 32 | using Nini.Config; |
@@ -34,9 +35,11 @@ using OpenSim.Region.Framework.Scenes; | |||
34 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
35 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | 38 | using OpenMetaverse; |
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | ||
38 | { | 41 | { |
39 | public class LocalUserServicesConnector : ISharedRegionModule | 42 | public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService |
40 | { | 43 | { |
41 | private static readonly ILog m_log = | 44 | private static readonly ILog m_log = |
42 | LogManager.GetLogger( | 45 | LogManager.GetLogger( |
@@ -46,6 +49,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
46 | 49 | ||
47 | private bool m_Enabled = false; | 50 | private bool m_Enabled = false; |
48 | 51 | ||
52 | #region ISharedRegionModule | ||
53 | |||
49 | public Type ReplaceableInterface | 54 | public Type ReplaceableInterface |
50 | { | 55 | { |
51 | get { return null; } | 56 | get { return null; } |
@@ -53,7 +58,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
53 | 58 | ||
54 | public string Name | 59 | public string Name |
55 | { | 60 | { |
56 | get { return "LocalUserServicesConnector"; } | 61 | get { return "LocalUserAccountServicesConnector"; } |
57 | } | 62 | } |
58 | 63 | ||
59 | public void Initialise(IConfigSource source) | 64 | public void Initialise(IConfigSource source) |
@@ -61,13 +66,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
61 | IConfig moduleConfig = source.Configs["Modules"]; | 66 | IConfig moduleConfig = source.Configs["Modules"]; |
62 | if (moduleConfig != null) | 67 | if (moduleConfig != null) |
63 | { | 68 | { |
64 | string name = moduleConfig.GetString("UserServices", ""); | 69 | string name = moduleConfig.GetString("UserAccountServices", ""); |
65 | if (name == Name) | 70 | if (name == Name) |
66 | { | 71 | { |
67 | IConfig userConfig = source.Configs["UserService"]; | 72 | IConfig userConfig = source.Configs["UserAccountService"]; |
68 | if (userConfig == null) | 73 | if (userConfig == null) |
69 | { | 74 | { |
70 | m_log.Error("[USER CONNECTOR]: UserService missing from OpenSim.ini"); | 75 | m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini"); |
71 | return; | 76 | return; |
72 | } | 77 | } |
73 | 78 | ||
@@ -87,7 +92,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
87 | 92 | ||
88 | if (m_UserService == null) | 93 | if (m_UserService == null) |
89 | { | 94 | { |
90 | m_log.Error("[USER CONNECTOR]: Can't load user service"); | 95 | m_log.Error("[USER CONNECTOR]: Can't load user account service"); |
91 | return; | 96 | return; |
92 | } | 97 | } |
93 | m_Enabled = true; | 98 | m_Enabled = true; |
@@ -127,5 +132,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
127 | if (!m_Enabled) | 132 | if (!m_Enabled) |
128 | return; | 133 | return; |
129 | } | 134 | } |
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IUserAccountService | ||
139 | |||
140 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | ||
141 | { | ||
142 | return m_UserService.GetUserAccount(scopeID, userID); | ||
143 | } | ||
144 | |||
145 | public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) | ||
146 | { | ||
147 | return m_UserService.GetUserAccount(scopeID, FirstName, LastName); | ||
148 | } | ||
149 | |||
150 | public UserAccount GetUserAccount(UUID scopeID, string Email) | ||
151 | { | ||
152 | return m_UserService.GetUserAccount(scopeID, Email); | ||
153 | } | ||
154 | |||
155 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
156 | { | ||
157 | return m_UserService.GetUserAccounts(scopeID, query); | ||
158 | } | ||
159 | |||
160 | // Update all updatable fields | ||
161 | // | ||
162 | public bool StoreUserAccount(UserAccount data) | ||
163 | { | ||
164 | return m_UserService.StoreUserAccount(data); | ||
165 | } | ||
166 | |||
167 | #endregion | ||
168 | |||
130 | } | 169 | } |
131 | } | 170 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index cef9129..7d61b20 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -34,9 +34,9 @@ using OpenSim.Region.Framework.Scenes; | |||
34 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
35 | using OpenSim.Services.Connectors; | 35 | using OpenSim.Services.Connectors; |
36 | 36 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | 37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts |
38 | { | 38 | { |
39 | public class RemoteUserServicesConnector : UserServicesConnector, | 39 | public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, |
40 | ISharedRegionModule, IUserAccountService | 40 | ISharedRegionModule, IUserAccountService |
41 | { | 41 | { |
42 | private static readonly ILog m_log = | 42 | private static readonly ILog m_log = |
@@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
52 | 52 | ||
53 | public string Name | 53 | public string Name |
54 | { | 54 | { |
55 | get { return "RemoteUserServicesConnector"; } | 55 | get { return "RemoteUserAccountServicesConnector"; } |
56 | } | 56 | } |
57 | 57 | ||
58 | public override void Initialise(IConfigSource source) | 58 | public override void Initialise(IConfigSource source) |
@@ -60,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
60 | IConfig moduleConfig = source.Configs["Modules"]; | 60 | IConfig moduleConfig = source.Configs["Modules"]; |
61 | if (moduleConfig != null) | 61 | if (moduleConfig != null) |
62 | { | 62 | { |
63 | string name = moduleConfig.GetString("UserServices", ""); | 63 | string name = moduleConfig.GetString("UserAccountServices", ""); |
64 | if (name == Name) | 64 | if (name == Name) |
65 | { | 65 | { |
66 | IConfig userConfig = source.Configs["UserService"]; | 66 | IConfig userConfig = source.Configs["UserAccountService"]; |
67 | if (userConfig == null) | 67 | if (userConfig == null) |
68 | { | 68 | { |
69 | m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); | 69 | m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpanSim.ini"); |
70 | return; | 70 | return; |
71 | } | 71 | } |
72 | 72 | ||