diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Estate')
6 files changed, 842 insertions, 30 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs index 4d49794..1659493 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | |||
@@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
60 | 60 | ||
61 | public void Initialise() | 61 | public void Initialise() |
62 | { | 62 | { |
63 | m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName); | 63 | // m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName); |
64 | 64 | ||
65 | m_module.Scene.AddCommand("Regions", m_module, "set terrain texture", | 65 | m_module.Scene.AddCommand("Regions", m_module, "set terrain texture", |
66 | "set terrain texture <number> <uuid> [<x>] [<y>]", | 66 | "set terrain texture <number> <uuid> [<x>] [<y>]", |
@@ -76,6 +76,13 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
76 | " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3, all corners = -1.", | 76 | " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3, all corners = -1.", |
77 | consoleSetTerrainHeights); | 77 | consoleSetTerrainHeights); |
78 | 78 | ||
79 | m_module.Scene.AddCommand("Regions", m_module, "set water height", | ||
80 | "set water height <height> [<x>] [<y>]", | ||
81 | "Sets the water height in meters. If <x> and <y> are specified, it will only set it on regions with a matching coordinate. " + | ||
82 | "Specify -1 in <x> or <y> to wildcard that coordinate.", | ||
83 | consoleSetWaterHeight); | ||
84 | |||
85 | |||
79 | m_module.Scene.AddCommand( | 86 | m_module.Scene.AddCommand( |
80 | "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand); | 87 | "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand); |
81 | } | 88 | } |
@@ -121,7 +128,29 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
121 | } | 128 | } |
122 | } | 129 | } |
123 | } | 130 | } |
124 | 131 | protected void consoleSetWaterHeight(string module, string[] args) | |
132 | { | ||
133 | string heightstring = args[3]; | ||
134 | |||
135 | int x = (args.Length > 4 ? int.Parse(args[4]) : -1); | ||
136 | int y = (args.Length > 5 ? int.Parse(args[5]) : -1); | ||
137 | |||
138 | if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x) | ||
139 | { | ||
140 | if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y) | ||
141 | { | ||
142 | double selectedheight = double.Parse(heightstring); | ||
143 | |||
144 | m_log.Debug("[ESTATEMODULE]: Setting water height in " + m_module.Scene.RegionInfo.RegionName + " to " + | ||
145 | string.Format(" {0}", selectedheight)); | ||
146 | m_module.Scene.RegionInfo.RegionSettings.WaterHeight = selectedheight; | ||
147 | |||
148 | m_module.Scene.RegionInfo.RegionSettings.Save(); | ||
149 | m_module.TriggerRegionInfoChange(); | ||
150 | m_module.sendRegionHandshakeToAll(); | ||
151 | } | ||
152 | } | ||
153 | } | ||
125 | protected void consoleSetTerrainHeights(string module, string[] args) | 154 | protected void consoleSetTerrainHeights(string module, string[] args) |
126 | { | 155 | { |
127 | string num = args[3]; | 156 | string num = args[3]; |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 834fd77..47390e7 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -576,7 +576,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
576 | if (!Scene.TeleportClientHome(user, s.ControllingClient)) | 576 | if (!Scene.TeleportClientHome(user, s.ControllingClient)) |
577 | { | 577 | { |
578 | s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out."); | 578 | s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out."); |
579 | s.ControllingClient.Close(); | 579 | Scene.CloseAgent(s.UUID, false); |
580 | } | 580 | } |
581 | } | 581 | } |
582 | } | 582 | } |
@@ -716,7 +716,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
716 | } | 716 | } |
717 | } | 717 | } |
718 | 718 | ||
719 | public void handleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) | 719 | public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) |
720 | { | 720 | { |
721 | SceneObjectPart part; | 721 | SceneObjectPart part; |
722 | 722 | ||
@@ -756,7 +756,9 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
756 | default: | 756 | default: |
757 | break; | 757 | break; |
758 | } | 758 | } |
759 | SendTelehubInfo(client); | 759 | |
760 | if (client != null) | ||
761 | SendTelehubInfo(client); | ||
760 | } | 762 | } |
761 | 763 | ||
762 | private void SendSimulatorBlueBoxMessage( | 764 | private void SendSimulatorBlueBoxMessage( |
@@ -811,7 +813,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
811 | if (!Scene.TeleportClientHome(prey, s.ControllingClient)) | 813 | if (!Scene.TeleportClientHome(prey, s.ControllingClient)) |
812 | { | 814 | { |
813 | s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); | 815 | s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); |
814 | s.ControllingClient.Close(); | 816 | Scene.CloseAgent(s.UUID, false); |
815 | } | 817 | } |
816 | } | 818 | } |
817 | } | 819 | } |
@@ -834,7 +836,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
834 | if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient)) | 836 | if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient)) |
835 | { | 837 | { |
836 | p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); | 838 | p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); |
837 | p.ControllingClient.Close(); | 839 | Scene.CloseAgent(p.UUID, false); |
838 | } | 840 | } |
839 | } | 841 | } |
840 | } | 842 | } |
@@ -843,26 +845,23 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
843 | 845 | ||
844 | private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) | 846 | private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) |
845 | { | 847 | { |
846 | if (TerrainUploader != null) | 848 | lock (this) |
847 | { | 849 | { |
848 | lock (TerrainUploader) | 850 | if ((TerrainUploader != null) && (XferID == TerrainUploader.XferID)) |
849 | { | 851 | { |
850 | if (XferID == TerrainUploader.XferID) | 852 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; |
851 | { | 853 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; |
852 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; | 854 | TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; |
853 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; | ||
854 | TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; | ||
855 | 855 | ||
856 | TerrainUploader = null; | 856 | TerrainUploader = null; |
857 | remoteClient.SendAlertMessage("Terrain Upload aborted by the client"); | 857 | remoteClient.SendAlertMessage("Terrain Upload aborted by the client"); |
858 | } | ||
859 | } | 858 | } |
860 | } | 859 | } |
861 | |||
862 | } | 860 | } |
861 | |||
863 | private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient) | 862 | private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient) |
864 | { | 863 | { |
865 | lock (TerrainUploader) | 864 | lock (this) |
866 | { | 865 | { |
867 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; | 866 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; |
868 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; | 867 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; |
@@ -921,22 +920,32 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
921 | 920 | ||
922 | private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) | 921 | private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) |
923 | { | 922 | { |
924 | if (TerrainUploader == null) | 923 | lock (this) |
925 | { | 924 | { |
926 | 925 | if (TerrainUploader == null) | |
927 | TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); | ||
928 | lock (TerrainUploader) | ||
929 | { | 926 | { |
927 | m_log.DebugFormat("Starting to receive uploaded terrain"); | ||
928 | TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); | ||
930 | remote_client.OnXferReceive += TerrainUploader.XferReceive; | 929 | remote_client.OnXferReceive += TerrainUploader.XferReceive; |
931 | remote_client.OnAbortXfer += AbortTerrainXferHandler; | 930 | remote_client.OnAbortXfer += AbortTerrainXferHandler; |
932 | TerrainUploader.TerrainUploadDone += HandleTerrainApplication; | 931 | TerrainUploader.TerrainUploadDone += HandleTerrainApplication; |
932 | TerrainUploader.RequestStartXfer(remote_client); | ||
933 | } | ||
934 | else | ||
935 | { | ||
936 | remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); | ||
933 | } | 937 | } |
934 | TerrainUploader.RequestStartXfer(remote_client); | ||
935 | |||
936 | } | 938 | } |
937 | else | 939 | } |
940 | |||
941 | public bool IsTerrainXfer(ulong xferID) | ||
942 | { | ||
943 | lock (this) | ||
938 | { | 944 | { |
939 | remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); | 945 | if (TerrainUploader == null) |
946 | return false; | ||
947 | else | ||
948 | return TerrainUploader.XferID == xferID; | ||
940 | } | 949 | } |
941 | } | 950 | } |
942 | 951 | ||
@@ -1221,7 +1230,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1221 | client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; | 1230 | client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; |
1222 | client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; | 1231 | client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; |
1223 | client.OnEstateChangeInfo += handleEstateChangeInfo; | 1232 | client.OnEstateChangeInfo += handleEstateChangeInfo; |
1224 | client.OnEstateManageTelehub += handleOnEstateManageTelehub; | 1233 | client.OnEstateManageTelehub += HandleOnEstateManageTelehub; |
1225 | client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; | 1234 | client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; |
1226 | client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; | 1235 | client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; |
1227 | client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; | 1236 | client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs index b8d8b10..2d74eaf 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs | |||
@@ -78,7 +78,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
78 | /// <param name="data"></param> | 78 | /// <param name="data"></param> |
79 | public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) | 79 | public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) |
80 | { | 80 | { |
81 | if (mXferID == xferID) | 81 | if (mXferID != xferID) |
82 | return; | ||
83 | |||
84 | lock (this) | ||
82 | { | 85 | { |
83 | if (m_asset.Data.Length > 1) | 86 | if (m_asset.Data.Length > 1) |
84 | { | 87 | { |
@@ -99,7 +102,6 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
99 | if ((packetID & 0x80000000) != 0) | 102 | if ((packetID & 0x80000000) != 0) |
100 | { | 103 | { |
101 | SendCompleteMessage(remoteClient); | 104 | SendCompleteMessage(remoteClient); |
102 | |||
103 | } | 105 | } |
104 | } | 106 | } |
105 | } | 107 | } |
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs new file mode 100644 index 0000000..73e706c --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs | |||
@@ -0,0 +1,218 @@ | |||
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 | |||
32 | using OpenSim.Services.Interfaces; | ||
33 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
34 | using OpenSim.Server.Base; | ||
35 | using OpenSim.Framework.Servers.HttpServer; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using log4net; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.World.Estate | ||
43 | { | ||
44 | public class EstateConnector | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected XEstateModule m_EstateModule; | ||
49 | |||
50 | public EstateConnector(XEstateModule module) | ||
51 | { | ||
52 | m_EstateModule = module; | ||
53 | } | ||
54 | |||
55 | public void SendTeleportHomeOneUser(uint EstateID, UUID PreyID) | ||
56 | { | ||
57 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
58 | sendData["METHOD"] = "teleport_home_one_user"; | ||
59 | |||
60 | sendData["EstateID"] = EstateID.ToString(); | ||
61 | sendData["PreyID"] = PreyID.ToString(); | ||
62 | |||
63 | SendToEstate(EstateID, sendData); | ||
64 | } | ||
65 | |||
66 | public void SendTeleportHomeAllUsers(uint EstateID) | ||
67 | { | ||
68 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
69 | sendData["METHOD"] = "teleport_home_all_users"; | ||
70 | |||
71 | sendData["EstateID"] = EstateID.ToString(); | ||
72 | |||
73 | SendToEstate(EstateID, sendData); | ||
74 | } | ||
75 | |||
76 | public bool SendUpdateCovenant(uint EstateID, UUID CovenantID) | ||
77 | { | ||
78 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
79 | sendData["METHOD"] = "update_covenant"; | ||
80 | |||
81 | sendData["CovenantID"] = CovenantID.ToString(); | ||
82 | sendData["EstateID"] = EstateID.ToString(); | ||
83 | |||
84 | // Handle local regions locally | ||
85 | // | ||
86 | foreach (Scene s in m_EstateModule.Scenes) | ||
87 | { | ||
88 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
89 | s.RegionInfo.RegionSettings.Covenant = CovenantID; | ||
90 | // s.ReloadEstateData(); | ||
91 | } | ||
92 | |||
93 | SendToEstate(EstateID, sendData); | ||
94 | |||
95 | return true; | ||
96 | } | ||
97 | |||
98 | public bool SendUpdateEstate(uint EstateID) | ||
99 | { | ||
100 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
101 | sendData["METHOD"] = "update_estate"; | ||
102 | |||
103 | sendData["EstateID"] = EstateID.ToString(); | ||
104 | |||
105 | // Handle local regions locally | ||
106 | // | ||
107 | foreach (Scene s in m_EstateModule.Scenes) | ||
108 | { | ||
109 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
110 | s.ReloadEstateData(); | ||
111 | } | ||
112 | |||
113 | SendToEstate(EstateID, sendData); | ||
114 | |||
115 | return true; | ||
116 | } | ||
117 | |||
118 | public void SendEstateMessage(uint EstateID, UUID FromID, string FromName, string Message) | ||
119 | { | ||
120 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
121 | sendData["METHOD"] = "estate_message"; | ||
122 | |||
123 | sendData["EstateID"] = EstateID.ToString(); | ||
124 | sendData["FromID"] = FromID.ToString(); | ||
125 | sendData["FromName"] = FromName; | ||
126 | sendData["Message"] = Message; | ||
127 | |||
128 | SendToEstate(EstateID, sendData); | ||
129 | } | ||
130 | |||
131 | private void SendToEstate(uint EstateID, Dictionary<string, object> sendData) | ||
132 | { | ||
133 | List<UUID> regions = m_EstateModule.Scenes[0].GetEstateRegions((int)EstateID); | ||
134 | |||
135 | UUID ScopeID = UUID.Zero; | ||
136 | |||
137 | // Handle local regions locally | ||
138 | // | ||
139 | lock (m_EstateModule.Scenes) | ||
140 | { | ||
141 | foreach (Scene s in m_EstateModule.Scenes) | ||
142 | { | ||
143 | if (regions.Contains(s.RegionInfo.RegionID)) | ||
144 | { | ||
145 | // All regions in one estate are in the same scope. | ||
146 | // Use that scope. | ||
147 | // | ||
148 | ScopeID = s.RegionInfo.ScopeID; | ||
149 | regions.Remove(s.RegionInfo.RegionID); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | |||
154 | // Our own region should always be in the above list. | ||
155 | // In a standalone this would not be true. But then, | ||
156 | // Scope ID is not relevat there. Use first scope. | ||
157 | // | ||
158 | if (ScopeID == UUID.Zero) | ||
159 | ScopeID = m_EstateModule.Scenes[0].RegionInfo.ScopeID; | ||
160 | |||
161 | // Don't send to the same instance twice | ||
162 | // | ||
163 | List<string> done = new List<string>(); | ||
164 | |||
165 | // Send to remote regions | ||
166 | // | ||
167 | foreach (UUID regionID in regions) | ||
168 | { | ||
169 | GridRegion region = m_EstateModule.Scenes[0].GridService.GetRegionByUUID(ScopeID, regionID); | ||
170 | if (region != null) | ||
171 | { | ||
172 | string url = "http://" + region.ExternalHostName + ":" + region.HttpPort; | ||
173 | if (done.Contains(url)) | ||
174 | continue; | ||
175 | |||
176 | Call(region, sendData); | ||
177 | done.Add(url); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | private bool Call(GridRegion region, Dictionary<string, object> sendData) | ||
183 | { | ||
184 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
185 | // m_log.DebugFormat("[XESTATE CONNECTOR]: queryString = {0}", reqString); | ||
186 | try | ||
187 | { | ||
188 | string url = "http://" + region.ExternalHostName + ":" + region.HttpPort; | ||
189 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
190 | url + "/estate", | ||
191 | reqString); | ||
192 | if (reply != string.Empty) | ||
193 | { | ||
194 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
195 | |||
196 | if (replyData.ContainsKey("RESULT")) | ||
197 | { | ||
198 | if (replyData["RESULT"].ToString().ToLower() == "true") | ||
199 | return true; | ||
200 | else | ||
201 | return false; | ||
202 | } | ||
203 | else | ||
204 | m_log.DebugFormat("[XESTATE CONNECTOR]: reply data does not contain result field"); | ||
205 | |||
206 | } | ||
207 | else | ||
208 | m_log.DebugFormat("[XESTATE CONNECTOR]: received empty reply"); | ||
209 | } | ||
210 | catch (Exception e) | ||
211 | { | ||
212 | m_log.DebugFormat("[XESTATE CONNECTOR]: Exception when contacting remote sim: {0}", e.Message); | ||
213 | } | ||
214 | |||
215 | return false; | ||
216 | } | ||
217 | } | ||
218 | } | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs new file mode 100644 index 0000000..f54ab2c --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs | |||
@@ -0,0 +1,256 @@ | |||
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.Reflection; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Server.Base; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | ||
44 | using Mono.Addins; | ||
45 | |||
46 | namespace OpenSim.Region.CoreModules.World.Estate | ||
47 | { | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XEstate")] | ||
49 | public class XEstateModule : ISharedRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | protected List<Scene> m_Scenes = new List<Scene>(); | ||
54 | protected bool m_InInfoUpdate = false; | ||
55 | |||
56 | public bool InInfoUpdate | ||
57 | { | ||
58 | get { return m_InInfoUpdate; } | ||
59 | set { m_InInfoUpdate = value; } | ||
60 | } | ||
61 | |||
62 | public List<Scene> Scenes | ||
63 | { | ||
64 | get { return m_Scenes; } | ||
65 | } | ||
66 | |||
67 | protected EstateConnector m_EstateConnector; | ||
68 | |||
69 | public void Initialise(IConfigSource config) | ||
70 | { | ||
71 | int port = 0; | ||
72 | |||
73 | IConfig estateConfig = config.Configs["Estate"]; | ||
74 | if (estateConfig != null) | ||
75 | { | ||
76 | port = estateConfig.GetInt("Port", 0); | ||
77 | } | ||
78 | |||
79 | m_EstateConnector = new EstateConnector(this); | ||
80 | |||
81 | // Instantiate the request handler | ||
82 | IHttpServer server = MainServer.GetHttpServer((uint)port); | ||
83 | server.AddStreamHandler(new EstateRequestHandler(this)); | ||
84 | } | ||
85 | |||
86 | public void PostInitialise() | ||
87 | { | ||
88 | } | ||
89 | |||
90 | public void Close() | ||
91 | { | ||
92 | } | ||
93 | |||
94 | public void AddRegion(Scene scene) | ||
95 | { | ||
96 | lock (m_Scenes) | ||
97 | m_Scenes.Add(scene); | ||
98 | |||
99 | scene.EventManager.OnNewClient += OnNewClient; | ||
100 | } | ||
101 | |||
102 | public void RegionLoaded(Scene scene) | ||
103 | { | ||
104 | IEstateModule em = scene.RequestModuleInterface<IEstateModule>(); | ||
105 | |||
106 | em.OnRegionInfoChange += OnRegionInfoChange; | ||
107 | em.OnEstateInfoChange += OnEstateInfoChange; | ||
108 | em.OnEstateMessage += OnEstateMessage; | ||
109 | } | ||
110 | |||
111 | public void RemoveRegion(Scene scene) | ||
112 | { | ||
113 | scene.EventManager.OnNewClient -= OnNewClient; | ||
114 | |||
115 | lock (m_Scenes) | ||
116 | m_Scenes.Remove(scene); | ||
117 | } | ||
118 | |||
119 | public string Name | ||
120 | { | ||
121 | get { return "EstateModule"; } | ||
122 | } | ||
123 | |||
124 | public Type ReplaceableInterface | ||
125 | { | ||
126 | get { return null; } | ||
127 | } | ||
128 | |||
129 | private Scene FindScene(UUID RegionID) | ||
130 | { | ||
131 | foreach (Scene s in Scenes) | ||
132 | { | ||
133 | if (s.RegionInfo.RegionID == RegionID) | ||
134 | return s; | ||
135 | } | ||
136 | |||
137 | return null; | ||
138 | } | ||
139 | |||
140 | private void OnRegionInfoChange(UUID RegionID) | ||
141 | { | ||
142 | Scene s = FindScene(RegionID); | ||
143 | if (s == null) | ||
144 | return; | ||
145 | |||
146 | if (!m_InInfoUpdate) | ||
147 | m_EstateConnector.SendUpdateCovenant(s.RegionInfo.EstateSettings.EstateID, s.RegionInfo.RegionSettings.Covenant); | ||
148 | } | ||
149 | |||
150 | private void OnEstateInfoChange(UUID RegionID) | ||
151 | { | ||
152 | Scene s = FindScene(RegionID); | ||
153 | if (s == null) | ||
154 | return; | ||
155 | |||
156 | if (!m_InInfoUpdate) | ||
157 | m_EstateConnector.SendUpdateEstate(s.RegionInfo.EstateSettings.EstateID); | ||
158 | } | ||
159 | |||
160 | private void OnEstateMessage(UUID RegionID, UUID FromID, string FromName, string Message) | ||
161 | { | ||
162 | Scene senderScenes = FindScene(RegionID); | ||
163 | if (senderScenes == null) | ||
164 | return; | ||
165 | |||
166 | uint estateID = senderScenes.RegionInfo.EstateSettings.EstateID; | ||
167 | |||
168 | foreach (Scene s in Scenes) | ||
169 | { | ||
170 | if (s.RegionInfo.EstateSettings.EstateID == estateID) | ||
171 | { | ||
172 | IDialogModule dm = s.RequestModuleInterface<IDialogModule>(); | ||
173 | |||
174 | if (dm != null) | ||
175 | { | ||
176 | dm.SendNotificationToUsersInRegion(FromID, FromName, | ||
177 | Message); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | if (!m_InInfoUpdate) | ||
182 | m_EstateConnector.SendEstateMessage(estateID, FromID, FromName, Message); | ||
183 | } | ||
184 | |||
185 | private void OnNewClient(IClientAPI client) | ||
186 | { | ||
187 | client.OnEstateTeleportOneUserHomeRequest += OnEstateTeleportOneUserHomeRequest; | ||
188 | client.OnEstateTeleportAllUsersHomeRequest += OnEstateTeleportAllUsersHomeRequest; | ||
189 | |||
190 | } | ||
191 | |||
192 | private void OnEstateTeleportOneUserHomeRequest(IClientAPI client, UUID invoice, UUID senderID, UUID prey) | ||
193 | { | ||
194 | if (prey == UUID.Zero) | ||
195 | return; | ||
196 | |||
197 | if (!(client.Scene is Scene)) | ||
198 | return; | ||
199 | |||
200 | Scene scene = (Scene)client.Scene; | ||
201 | |||
202 | uint estateID = scene.RegionInfo.EstateSettings.EstateID; | ||
203 | |||
204 | if (!scene.Permissions.CanIssueEstateCommand(client.AgentId, false)) | ||
205 | return; | ||
206 | |||
207 | foreach (Scene s in Scenes) | ||
208 | { | ||
209 | if (s == scene) | ||
210 | continue; // Already handles by estate module | ||
211 | if (s.RegionInfo.EstateSettings.EstateID != estateID) | ||
212 | continue; | ||
213 | |||
214 | ScenePresence p = scene.GetScenePresence(prey); | ||
215 | if (p != null && !p.IsChildAgent) | ||
216 | { | ||
217 | p.ControllingClient.SendTeleportStart(16); | ||
218 | scene.TeleportClientHome(prey, p.ControllingClient); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | m_EstateConnector.SendTeleportHomeOneUser(estateID, prey); | ||
223 | } | ||
224 | |||
225 | private void OnEstateTeleportAllUsersHomeRequest(IClientAPI client, UUID invoice, UUID senderID) | ||
226 | { | ||
227 | if (!(client.Scene is Scene)) | ||
228 | return; | ||
229 | |||
230 | Scene scene = (Scene)client.Scene; | ||
231 | |||
232 | uint estateID = scene.RegionInfo.EstateSettings.EstateID; | ||
233 | |||
234 | if (!scene.Permissions.CanIssueEstateCommand(client.AgentId, false)) | ||
235 | return; | ||
236 | |||
237 | foreach (Scene s in Scenes) | ||
238 | { | ||
239 | if (s == scene) | ||
240 | continue; // Already handles by estate module | ||
241 | if (s.RegionInfo.EstateSettings.EstateID != estateID) | ||
242 | continue; | ||
243 | |||
244 | scene.ForEachScenePresence(delegate(ScenePresence p) { | ||
245 | if (p != null && !p.IsChildAgent) | ||
246 | { | ||
247 | p.ControllingClient.SendTeleportStart(16); | ||
248 | scene.TeleportClientHome(p.ControllingClient.AgentId, p.ControllingClient); | ||
249 | } | ||
250 | }); | ||
251 | } | ||
252 | |||
253 | m_EstateConnector.SendTeleportHomeAllUsers(estateID); | ||
254 | } | ||
255 | } | ||
256 | } | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs new file mode 100644 index 0000000..2366767 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs | |||
@@ -0,0 +1,298 @@ | |||
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.Xml; | ||
33 | |||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | |||
40 | using OpenMetaverse; | ||
41 | using log4net; | ||
42 | |||
43 | namespace OpenSim.Region.CoreModules.World.Estate | ||
44 | { | ||
45 | public class EstateRequestHandler : BaseStreamHandler | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | protected XEstateModule m_EstateModule; | ||
50 | protected Object m_RequestLock = new Object(); | ||
51 | |||
52 | public EstateRequestHandler(XEstateModule fmodule) | ||
53 | : base("POST", "/estate") | ||
54 | { | ||
55 | m_EstateModule = fmodule; | ||
56 | } | ||
57 | |||
58 | protected override byte[] ProcessRequest(string path, Stream requestData, | ||
59 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
60 | { | ||
61 | StreamReader sr = new StreamReader(requestData); | ||
62 | string body = sr.ReadToEnd(); | ||
63 | sr.Close(); | ||
64 | body = body.Trim(); | ||
65 | |||
66 | m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body); | ||
67 | |||
68 | try | ||
69 | { | ||
70 | lock (m_RequestLock) | ||
71 | { | ||
72 | Dictionary<string, object> request = | ||
73 | ServerUtils.ParseQueryString(body); | ||
74 | |||
75 | if (!request.ContainsKey("METHOD")) | ||
76 | return FailureResult(); | ||
77 | |||
78 | string method = request["METHOD"].ToString(); | ||
79 | request.Remove("METHOD"); | ||
80 | |||
81 | try | ||
82 | { | ||
83 | m_EstateModule.InInfoUpdate = false; | ||
84 | |||
85 | switch (method) | ||
86 | { | ||
87 | case "update_covenant": | ||
88 | return UpdateCovenant(request); | ||
89 | case "update_estate": | ||
90 | return UpdateEstate(request); | ||
91 | case "estate_message": | ||
92 | return EstateMessage(request); | ||
93 | case "teleport_home_one_user": | ||
94 | return TeleportHomeOneUser(request); | ||
95 | case "teleport_home_all_users": | ||
96 | return TeleportHomeAllUsers(request); | ||
97 | } | ||
98 | } | ||
99 | finally | ||
100 | { | ||
101 | m_EstateModule.InInfoUpdate = false; | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | catch (Exception e) | ||
106 | { | ||
107 | m_log.Debug("[XESTATE]: Exception {0}" + e.ToString()); | ||
108 | } | ||
109 | |||
110 | return FailureResult(); | ||
111 | } | ||
112 | |||
113 | byte[] TeleportHomeAllUsers(Dictionary<string, object> request) | ||
114 | { | ||
115 | UUID PreyID = UUID.Zero; | ||
116 | int EstateID = 0; | ||
117 | |||
118 | if (!request.ContainsKey("EstateID")) | ||
119 | return FailureResult(); | ||
120 | |||
121 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
122 | return FailureResult(); | ||
123 | |||
124 | foreach (Scene s in m_EstateModule.Scenes) | ||
125 | { | ||
126 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
127 | { | ||
128 | s.ForEachScenePresence(delegate(ScenePresence p) { | ||
129 | if (p != null && !p.IsChildAgent) | ||
130 | { | ||
131 | p.ControllingClient.SendTeleportStart(16); | ||
132 | s.TeleportClientHome(p.ControllingClient.AgentId, p.ControllingClient); | ||
133 | } | ||
134 | }); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | return SuccessResult(); | ||
139 | } | ||
140 | |||
141 | byte[] TeleportHomeOneUser(Dictionary<string, object> request) | ||
142 | { | ||
143 | UUID PreyID = UUID.Zero; | ||
144 | int EstateID = 0; | ||
145 | |||
146 | if (!request.ContainsKey("PreyID") || | ||
147 | !request.ContainsKey("EstateID")) | ||
148 | { | ||
149 | return FailureResult(); | ||
150 | } | ||
151 | |||
152 | if (!UUID.TryParse(request["PreyID"].ToString(), out PreyID)) | ||
153 | return FailureResult(); | ||
154 | |||
155 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
156 | return FailureResult(); | ||
157 | |||
158 | foreach (Scene s in m_EstateModule.Scenes) | ||
159 | { | ||
160 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
161 | { | ||
162 | ScenePresence p = s.GetScenePresence(PreyID); | ||
163 | if (p != null && !p.IsChildAgent) | ||
164 | { | ||
165 | p.ControllingClient.SendTeleportStart(16); | ||
166 | s.TeleportClientHome(PreyID, p.ControllingClient); | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
171 | return SuccessResult(); | ||
172 | } | ||
173 | |||
174 | byte[] EstateMessage(Dictionary<string, object> request) | ||
175 | { | ||
176 | UUID FromID = UUID.Zero; | ||
177 | string FromName = String.Empty; | ||
178 | string Message = String.Empty; | ||
179 | int EstateID = 0; | ||
180 | |||
181 | if (!request.ContainsKey("FromID") || | ||
182 | !request.ContainsKey("FromName") || | ||
183 | !request.ContainsKey("Message") || | ||
184 | !request.ContainsKey("EstateID")) | ||
185 | { | ||
186 | return FailureResult(); | ||
187 | } | ||
188 | |||
189 | if (!UUID.TryParse(request["FromID"].ToString(), out FromID)) | ||
190 | return FailureResult(); | ||
191 | |||
192 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
193 | return FailureResult(); | ||
194 | |||
195 | FromName = request["FromName"].ToString(); | ||
196 | Message = request["Message"].ToString(); | ||
197 | |||
198 | foreach (Scene s in m_EstateModule.Scenes) | ||
199 | { | ||
200 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
201 | { | ||
202 | IDialogModule dm = s.RequestModuleInterface<IDialogModule>(); | ||
203 | |||
204 | if (dm != null) | ||
205 | { | ||
206 | dm.SendNotificationToUsersInRegion(FromID, FromName, | ||
207 | Message); | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
212 | return SuccessResult(); | ||
213 | } | ||
214 | |||
215 | byte[] UpdateCovenant(Dictionary<string, object> request) | ||
216 | { | ||
217 | UUID CovenantID = UUID.Zero; | ||
218 | int EstateID = 0; | ||
219 | |||
220 | if (!request.ContainsKey("CovenantID") || !request.ContainsKey("EstateID")) | ||
221 | return FailureResult(); | ||
222 | |||
223 | if (!UUID.TryParse(request["CovenantID"].ToString(), out CovenantID)) | ||
224 | return FailureResult(); | ||
225 | |||
226 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
227 | return FailureResult(); | ||
228 | |||
229 | foreach (Scene s in m_EstateModule.Scenes) | ||
230 | { | ||
231 | if (s.RegionInfo.EstateSettings.EstateID == (uint)EstateID) | ||
232 | s.RegionInfo.RegionSettings.Covenant = CovenantID; | ||
233 | } | ||
234 | |||
235 | return SuccessResult(); | ||
236 | } | ||
237 | |||
238 | byte[] UpdateEstate(Dictionary<string, object> request) | ||
239 | { | ||
240 | int EstateID = 0; | ||
241 | |||
242 | if (!request.ContainsKey("EstateID")) | ||
243 | return FailureResult(); | ||
244 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
245 | return FailureResult(); | ||
246 | |||
247 | foreach (Scene s in m_EstateModule.Scenes) | ||
248 | { | ||
249 | if (s.RegionInfo.EstateSettings.EstateID == (uint)EstateID) | ||
250 | s.ReloadEstateData(); | ||
251 | } | ||
252 | return SuccessResult(); | ||
253 | } | ||
254 | |||
255 | private byte[] FailureResult() | ||
256 | { | ||
257 | return BoolResult(false); | ||
258 | } | ||
259 | |||
260 | private byte[] SuccessResult() | ||
261 | { | ||
262 | return BoolResult(true); | ||
263 | } | ||
264 | |||
265 | private byte[] BoolResult(bool value) | ||
266 | { | ||
267 | XmlDocument doc = new XmlDocument(); | ||
268 | |||
269 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
270 | "", ""); | ||
271 | |||
272 | doc.AppendChild(xmlnode); | ||
273 | |||
274 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
275 | ""); | ||
276 | |||
277 | doc.AppendChild(rootElement); | ||
278 | |||
279 | XmlElement result = doc.CreateElement("", "RESULT", ""); | ||
280 | result.AppendChild(doc.CreateTextNode(value.ToString())); | ||
281 | |||
282 | rootElement.AppendChild(result); | ||
283 | |||
284 | return DocToBytes(doc); | ||
285 | } | ||
286 | |||
287 | private byte[] DocToBytes(XmlDocument doc) | ||
288 | { | ||
289 | MemoryStream ms = new MemoryStream(); | ||
290 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
291 | xw.Formatting = Formatting.Indented; | ||
292 | doc.WriteTo(xw); | ||
293 | xw.Flush(); | ||
294 | |||
295 | return ms.ToArray(); | ||
296 | } | ||
297 | } | ||
298 | } | ||