diff options
author | Jeff Ames | 2009-04-06 14:24:13 +0000 |
---|---|---|
committer | Jeff Ames | 2009-04-06 14:24:13 +0000 |
commit | 5f34bd73fbca765064c4b3811d1f67da36cbf5ae (patch) | |
tree | a91d8995b5677a524038e8b43c168ac2a28dd2c4 /OpenSim/Framework | |
parent | Thank you, Intimidated, for a patch too fix the movement animation handling (diff) | |
download | opensim-SC-5f34bd73fbca765064c4b3811d1f67da36cbf5ae.zip opensim-SC-5f34bd73fbca765064c4b3811d1f67da36cbf5ae.tar.gz opensim-SC-5f34bd73fbca765064c4b3811d1f67da36cbf5ae.tar.bz2 opensim-SC-5f34bd73fbca765064c4b3811d1f67da36cbf5ae.tar.xz |
Update svn properties.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Animation.cs | 188 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Clients/RegionClient.cs | 1262 | ||||
-rw-r--r-- | OpenSim/Framework/ISceneObject.cs | 84 |
3 files changed, 767 insertions, 767 deletions
diff --git a/OpenSim/Framework/Animation.cs b/OpenSim/Framework/Animation.cs index cda8387..6cfedda 100644 --- a/OpenSim/Framework/Animation.cs +++ b/OpenSim/Framework/Animation.cs | |||
@@ -1,94 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenMetaverse; | 29 | using OpenMetaverse; |
30 | using OpenMetaverse.StructuredData; | 30 | using OpenMetaverse.StructuredData; |
31 | 31 | ||
32 | namespace OpenSim.Framework | 32 | namespace OpenSim.Framework |
33 | { | 33 | { |
34 | [Serializable] | 34 | [Serializable] |
35 | public class Animation | 35 | public class Animation |
36 | { | 36 | { |
37 | private UUID animID; | 37 | private UUID animID; |
38 | public UUID AnimID | 38 | public UUID AnimID |
39 | { | 39 | { |
40 | get { return animID; } | 40 | get { return animID; } |
41 | set { animID = value; } | 41 | set { animID = value; } |
42 | } | 42 | } |
43 | 43 | ||
44 | private int sequenceNum; | 44 | private int sequenceNum; |
45 | public int SequenceNum | 45 | public int SequenceNum |
46 | { | 46 | { |
47 | get { return sequenceNum; } | 47 | get { return sequenceNum; } |
48 | set { sequenceNum = value; } | 48 | set { sequenceNum = value; } |
49 | } | 49 | } |
50 | 50 | ||
51 | private UUID objectID; | 51 | private UUID objectID; |
52 | public UUID ObjectID | 52 | public UUID ObjectID |
53 | { | 53 | { |
54 | get { return objectID; } | 54 | get { return objectID; } |
55 | set { objectID = value; } | 55 | set { objectID = value; } |
56 | } | 56 | } |
57 | 57 | ||
58 | public Animation() | 58 | public Animation() |
59 | { | 59 | { |
60 | } | 60 | } |
61 | 61 | ||
62 | public Animation(UUID animID, int sequenceNum, UUID objectID) | 62 | public Animation(UUID animID, int sequenceNum, UUID objectID) |
63 | { | 63 | { |
64 | this.animID = animID; | 64 | this.animID = animID; |
65 | this.sequenceNum = sequenceNum; | 65 | this.sequenceNum = sequenceNum; |
66 | this.objectID = objectID; | 66 | this.objectID = objectID; |
67 | } | 67 | } |
68 | 68 | ||
69 | public Animation(OSDMap args) | 69 | public Animation(OSDMap args) |
70 | { | 70 | { |
71 | UnpackUpdateMessage(args); | 71 | UnpackUpdateMessage(args); |
72 | } | 72 | } |
73 | 73 | ||
74 | public OSDMap PackUpdateMessage() | 74 | public OSDMap PackUpdateMessage() |
75 | { | 75 | { |
76 | OSDMap anim = new OSDMap(); | 76 | OSDMap anim = new OSDMap(); |
77 | anim["animation"] = OSD.FromUUID(animID); | 77 | anim["animation"] = OSD.FromUUID(animID); |
78 | anim["object_id"] = OSD.FromUUID(objectID); | 78 | anim["object_id"] = OSD.FromUUID(objectID); |
79 | anim["seq_num"] = OSD.FromInteger(sequenceNum); | 79 | anim["seq_num"] = OSD.FromInteger(sequenceNum); |
80 | return anim; | 80 | return anim; |
81 | } | 81 | } |
82 | 82 | ||
83 | public void UnpackUpdateMessage(OSDMap args) | 83 | public void UnpackUpdateMessage(OSDMap args) |
84 | { | 84 | { |
85 | if (args["animation"] != null) | 85 | if (args["animation"] != null) |
86 | animID = args["animation"].AsUUID(); | 86 | animID = args["animation"].AsUUID(); |
87 | if (args["object_id"] != null) | 87 | if (args["object_id"] != null) |
88 | objectID = args["object_id"].AsUUID(); | 88 | objectID = args["object_id"].AsUUID(); |
89 | if (args["seq_num"] != null) | 89 | if (args["seq_num"] != null) |
90 | sequenceNum = args["seq_num"].AsInteger(); | 90 | sequenceNum = args["seq_num"].AsInteger(); |
91 | } | 91 | } |
92 | 92 | ||
93 | } | 93 | } |
94 | } | 94 | } |
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 196bcf9..27353b0 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs | |||
@@ -1,631 +1,631 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text; | 33 | using System.Text; |
34 | 34 | ||
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenMetaverse.StructuredData; | 36 | using OpenMetaverse.StructuredData; |
37 | 37 | ||
38 | using log4net; | 38 | using log4net; |
39 | 39 | ||
40 | namespace OpenSim.Framework.Communications.Clients | 40 | namespace OpenSim.Framework.Communications.Clients |
41 | { | 41 | { |
42 | public class RegionClient | 42 | public class RegionClient |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit) | 46 | public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit) |
47 | { | 47 | { |
48 | // Eventually, we want to use a caps url instead of the agentID | 48 | // Eventually, we want to use a caps url instead of the agentID |
49 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; | 49 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; |
50 | //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); | 50 | //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); |
51 | 51 | ||
52 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); | 52 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); |
53 | AgentCreateRequest.Method = "POST"; | 53 | AgentCreateRequest.Method = "POST"; |
54 | AgentCreateRequest.ContentType = "application/json"; | 54 | AgentCreateRequest.ContentType = "application/json"; |
55 | AgentCreateRequest.Timeout = 10000; | 55 | AgentCreateRequest.Timeout = 10000; |
56 | //AgentCreateRequest.KeepAlive = false; | 56 | //AgentCreateRequest.KeepAlive = false; |
57 | 57 | ||
58 | // Fill it in | 58 | // Fill it in |
59 | OSDMap args = null; | 59 | OSDMap args = null; |
60 | try | 60 | try |
61 | { | 61 | { |
62 | args = aCircuit.PackAgentCircuitData(); | 62 | args = aCircuit.PackAgentCircuitData(); |
63 | } | 63 | } |
64 | catch (Exception e) | 64 | catch (Exception e) |
65 | { | 65 | { |
66 | m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); | 66 | m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); |
67 | } | 67 | } |
68 | // Add the regionhandle of the destination region | 68 | // Add the regionhandle of the destination region |
69 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | 69 | ulong regionHandle = GetRegionHandle(region.RegionHandle); |
70 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | 70 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); |
71 | 71 | ||
72 | string strBuffer = ""; | 72 | string strBuffer = ""; |
73 | byte[] buffer = new byte[1]; | 73 | byte[] buffer = new byte[1]; |
74 | try | 74 | try |
75 | { | 75 | { |
76 | strBuffer = OSDParser.SerializeJsonString(args); | 76 | strBuffer = OSDParser.SerializeJsonString(args); |
77 | UTF8Encoding str = new UTF8Encoding(); | 77 | UTF8Encoding str = new UTF8Encoding(); |
78 | buffer = str.GetBytes(strBuffer); | 78 | buffer = str.GetBytes(strBuffer); |
79 | 79 | ||
80 | } | 80 | } |
81 | catch (Exception e) | 81 | catch (Exception e) |
82 | { | 82 | { |
83 | m_log.WarnFormat("[OSG2]: Exception thrown on serialization of ChildCreate: {0}", e.Message); | 83 | m_log.WarnFormat("[OSG2]: Exception thrown on serialization of ChildCreate: {0}", e.Message); |
84 | // ignore. buffer will be empty, caller should check. | 84 | // ignore. buffer will be empty, caller should check. |
85 | } | 85 | } |
86 | 86 | ||
87 | Stream os = null; | 87 | Stream os = null; |
88 | try | 88 | try |
89 | { // send the Post | 89 | { // send the Post |
90 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send | 90 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send |
91 | os = AgentCreateRequest.GetRequestStream(); | 91 | os = AgentCreateRequest.GetRequestStream(); |
92 | os.Write(buffer, 0, strBuffer.Length); //Send it | 92 | os.Write(buffer, 0, strBuffer.Length); //Send it |
93 | os.Close(); | 93 | os.Close(); |
94 | //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); | 94 | //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); |
95 | } | 95 | } |
96 | //catch (WebException ex) | 96 | //catch (WebException ex) |
97 | catch | 97 | catch |
98 | { | 98 | { |
99 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); | 99 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); |
100 | 100 | ||
101 | return false; | 101 | return false; |
102 | } | 102 | } |
103 | 103 | ||
104 | // Let's wait for the response | 104 | // Let's wait for the response |
105 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | 105 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); |
106 | 106 | ||
107 | try | 107 | try |
108 | { | 108 | { |
109 | WebResponse webResponse = AgentCreateRequest.GetResponse(); | 109 | WebResponse webResponse = AgentCreateRequest.GetResponse(); |
110 | if (webResponse == null) | 110 | if (webResponse == null) |
111 | { | 111 | { |
112 | m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); | 112 | m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); |
113 | } | 113 | } |
114 | 114 | ||
115 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 115 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
116 | //reply = sr.ReadToEnd().Trim(); | 116 | //reply = sr.ReadToEnd().Trim(); |
117 | sr.ReadToEnd().Trim(); | 117 | sr.ReadToEnd().Trim(); |
118 | sr.Close(); | 118 | sr.Close(); |
119 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | 119 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); |
120 | 120 | ||
121 | } | 121 | } |
122 | catch (WebException ex) | 122 | catch (WebException ex) |
123 | { | 123 | { |
124 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | 124 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); |
125 | // ignore, really | 125 | // ignore, really |
126 | } | 126 | } |
127 | 127 | ||
128 | return true; | 128 | return true; |
129 | 129 | ||
130 | } | 130 | } |
131 | 131 | ||
132 | public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) | 132 | public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) |
133 | { | 133 | { |
134 | // Eventually, we want to use a caps url instead of the agentID | 134 | // Eventually, we want to use a caps url instead of the agentID |
135 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; | 135 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; |
136 | //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); | 136 | //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); |
137 | 137 | ||
138 | HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); | 138 | HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); |
139 | ChildUpdateRequest.Method = "PUT"; | 139 | ChildUpdateRequest.Method = "PUT"; |
140 | ChildUpdateRequest.ContentType = "application/json"; | 140 | ChildUpdateRequest.ContentType = "application/json"; |
141 | ChildUpdateRequest.Timeout = 10000; | 141 | ChildUpdateRequest.Timeout = 10000; |
142 | //ChildUpdateRequest.KeepAlive = false; | 142 | //ChildUpdateRequest.KeepAlive = false; |
143 | 143 | ||
144 | // Fill it in | 144 | // Fill it in |
145 | OSDMap args = null; | 145 | OSDMap args = null; |
146 | try | 146 | try |
147 | { | 147 | { |
148 | args = cAgentData.Pack(); | 148 | args = cAgentData.Pack(); |
149 | } | 149 | } |
150 | catch (Exception e) | 150 | catch (Exception e) |
151 | { | 151 | { |
152 | m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); | 152 | m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); |
153 | } | 153 | } |
154 | // Add the regionhandle of the destination region | 154 | // Add the regionhandle of the destination region |
155 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | 155 | ulong regionHandle = GetRegionHandle(region.RegionHandle); |
156 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | 156 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); |
157 | 157 | ||
158 | string strBuffer = ""; | 158 | string strBuffer = ""; |
159 | byte[] buffer = new byte[1]; | 159 | byte[] buffer = new byte[1]; |
160 | try | 160 | try |
161 | { | 161 | { |
162 | strBuffer = OSDParser.SerializeJsonString(args); | 162 | strBuffer = OSDParser.SerializeJsonString(args); |
163 | UTF8Encoding str = new UTF8Encoding(); | 163 | UTF8Encoding str = new UTF8Encoding(); |
164 | buffer = str.GetBytes(strBuffer); | 164 | buffer = str.GetBytes(strBuffer); |
165 | 165 | ||
166 | } | 166 | } |
167 | catch (Exception e) | 167 | catch (Exception e) |
168 | { | 168 | { |
169 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); | 169 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); |
170 | // ignore. buffer will be empty, caller should check. | 170 | // ignore. buffer will be empty, caller should check. |
171 | } | 171 | } |
172 | 172 | ||
173 | Stream os = null; | 173 | Stream os = null; |
174 | try | 174 | try |
175 | { // send the Post | 175 | { // send the Post |
176 | ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send | 176 | ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send |
177 | os = ChildUpdateRequest.GetRequestStream(); | 177 | os = ChildUpdateRequest.GetRequestStream(); |
178 | os.Write(buffer, 0, strBuffer.Length); //Send it | 178 | os.Write(buffer, 0, strBuffer.Length); //Send it |
179 | os.Close(); | 179 | os.Close(); |
180 | //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); | 180 | //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); |
181 | } | 181 | } |
182 | //catch (WebException ex) | 182 | //catch (WebException ex) |
183 | catch | 183 | catch |
184 | { | 184 | { |
185 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); | 185 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); |
186 | 186 | ||
187 | return false; | 187 | return false; |
188 | } | 188 | } |
189 | 189 | ||
190 | // Let's wait for the response | 190 | // Let's wait for the response |
191 | //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); | 191 | //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); |
192 | 192 | ||
193 | try | 193 | try |
194 | { | 194 | { |
195 | WebResponse webResponse = ChildUpdateRequest.GetResponse(); | 195 | WebResponse webResponse = ChildUpdateRequest.GetResponse(); |
196 | if (webResponse == null) | 196 | if (webResponse == null) |
197 | { | 197 | { |
198 | m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); | 198 | m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); |
199 | } | 199 | } |
200 | 200 | ||
201 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 201 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
202 | //reply = sr.ReadToEnd().Trim(); | 202 | //reply = sr.ReadToEnd().Trim(); |
203 | sr.ReadToEnd().Trim(); | 203 | sr.ReadToEnd().Trim(); |
204 | sr.Close(); | 204 | sr.Close(); |
205 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | 205 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); |
206 | 206 | ||
207 | } | 207 | } |
208 | catch (WebException ex) | 208 | catch (WebException ex) |
209 | { | 209 | { |
210 | m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); | 210 | m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); |
211 | // ignore, really | 211 | // ignore, really |
212 | } | 212 | } |
213 | 213 | ||
214 | return true; | 214 | return true; |
215 | } | 215 | } |
216 | 216 | ||
217 | public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) | 217 | public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) |
218 | { | 218 | { |
219 | agent = null; | 219 | agent = null; |
220 | // Eventually, we want to use a caps url instead of the agentID | 220 | // Eventually, we want to use a caps url instead of the agentID |
221 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; | 221 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; |
222 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); | 222 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); |
223 | 223 | ||
224 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | 224 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); |
225 | request.Method = "GET"; | 225 | request.Method = "GET"; |
226 | request.Timeout = 10000; | 226 | request.Timeout = 10000; |
227 | //request.Headers.Add("authorization", ""); // coming soon | 227 | //request.Headers.Add("authorization", ""); // coming soon |
228 | 228 | ||
229 | HttpWebResponse webResponse = null; | 229 | HttpWebResponse webResponse = null; |
230 | string reply = string.Empty; | 230 | string reply = string.Empty; |
231 | try | 231 | try |
232 | { | 232 | { |
233 | webResponse = (HttpWebResponse)request.GetResponse(); | 233 | webResponse = (HttpWebResponse)request.GetResponse(); |
234 | if (webResponse == null) | 234 | if (webResponse == null) |
235 | { | 235 | { |
236 | m_log.Info("[REST COMMS]: Null reply on agent get "); | 236 | m_log.Info("[REST COMMS]: Null reply on agent get "); |
237 | } | 237 | } |
238 | 238 | ||
239 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 239 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
240 | reply = sr.ReadToEnd().Trim(); | 240 | reply = sr.ReadToEnd().Trim(); |
241 | sr.Close(); | 241 | sr.Close(); |
242 | 242 | ||
243 | //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); | 243 | //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); |
244 | 244 | ||
245 | } | 245 | } |
246 | catch (WebException ex) | 246 | catch (WebException ex) |
247 | { | 247 | { |
248 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); | 248 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); |
249 | // ignore, really | 249 | // ignore, really |
250 | return false; | 250 | return false; |
251 | } | 251 | } |
252 | 252 | ||
253 | if (webResponse.StatusCode == HttpStatusCode.OK) | 253 | if (webResponse.StatusCode == HttpStatusCode.OK) |
254 | { | 254 | { |
255 | // we know it's jason | 255 | // we know it's jason |
256 | OSDMap args = GetOSDMap(reply); | 256 | OSDMap args = GetOSDMap(reply); |
257 | if (args == null) | 257 | if (args == null) |
258 | { | 258 | { |
259 | //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); | 259 | //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); |
260 | return false; | 260 | return false; |
261 | } | 261 | } |
262 | 262 | ||
263 | agent = new CompleteAgentData(); | 263 | agent = new CompleteAgentData(); |
264 | agent.Unpack(args); | 264 | agent.Unpack(args); |
265 | return true; | 265 | return true; |
266 | } | 266 | } |
267 | 267 | ||
268 | //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); | 268 | //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); |
269 | return false; | 269 | return false; |
270 | } | 270 | } |
271 | 271 | ||
272 | public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) | 272 | public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) |
273 | { | 273 | { |
274 | //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); | 274 | //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); |
275 | 275 | ||
276 | WebRequest request = WebRequest.Create(uri); | 276 | WebRequest request = WebRequest.Create(uri); |
277 | request.Method = "DELETE"; | 277 | request.Method = "DELETE"; |
278 | request.Timeout = 10000; | 278 | request.Timeout = 10000; |
279 | 279 | ||
280 | try | 280 | try |
281 | { | 281 | { |
282 | WebResponse webResponse = request.GetResponse(); | 282 | WebResponse webResponse = request.GetResponse(); |
283 | if (webResponse == null) | 283 | if (webResponse == null) |
284 | { | 284 | { |
285 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | 285 | m_log.Info("[REST COMMS]: Null reply on agent delete "); |
286 | } | 286 | } |
287 | 287 | ||
288 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 288 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
289 | //reply = sr.ReadToEnd().Trim(); | 289 | //reply = sr.ReadToEnd().Trim(); |
290 | sr.ReadToEnd().Trim(); | 290 | sr.ReadToEnd().Trim(); |
291 | sr.Close(); | 291 | sr.Close(); |
292 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | 292 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); |
293 | 293 | ||
294 | } | 294 | } |
295 | catch (WebException ex) | 295 | catch (WebException ex) |
296 | { | 296 | { |
297 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | 297 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); |
298 | // ignore, really | 298 | // ignore, really |
299 | } | 299 | } |
300 | 300 | ||
301 | return true; | 301 | return true; |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | public bool DoCloseAgentCall(RegionInfo region, UUID id) | 305 | public bool DoCloseAgentCall(RegionInfo region, UUID id) |
306 | { | 306 | { |
307 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; | 307 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; |
308 | 308 | ||
309 | //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); | 309 | //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); |
310 | 310 | ||
311 | WebRequest request = WebRequest.Create(uri); | 311 | WebRequest request = WebRequest.Create(uri); |
312 | request.Method = "DELETE"; | 312 | request.Method = "DELETE"; |
313 | request.Timeout = 10000; | 313 | request.Timeout = 10000; |
314 | 314 | ||
315 | try | 315 | try |
316 | { | 316 | { |
317 | WebResponse webResponse = request.GetResponse(); | 317 | WebResponse webResponse = request.GetResponse(); |
318 | if (webResponse == null) | 318 | if (webResponse == null) |
319 | { | 319 | { |
320 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | 320 | m_log.Info("[REST COMMS]: Null reply on agent delete "); |
321 | } | 321 | } |
322 | 322 | ||
323 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 323 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
324 | //reply = sr.ReadToEnd().Trim(); | 324 | //reply = sr.ReadToEnd().Trim(); |
325 | sr.ReadToEnd().Trim(); | 325 | sr.ReadToEnd().Trim(); |
326 | sr.Close(); | 326 | sr.Close(); |
327 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | 327 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); |
328 | 328 | ||
329 | } | 329 | } |
330 | catch (WebException ex) | 330 | catch (WebException ex) |
331 | { | 331 | { |
332 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | 332 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); |
333 | // ignore, really | 333 | // ignore, really |
334 | } | 334 | } |
335 | 335 | ||
336 | return true; | 336 | return true; |
337 | } | 337 | } |
338 | 338 | ||
339 | public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, bool allowScriptCrossing) | 339 | public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, bool allowScriptCrossing) |
340 | { | 340 | { |
341 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | 341 | ulong regionHandle = GetRegionHandle(region.RegionHandle); |
342 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; | 342 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; |
343 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); | 343 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); |
344 | 344 | ||
345 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); | 345 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); |
346 | ObjectCreateRequest.Method = "POST"; | 346 | ObjectCreateRequest.Method = "POST"; |
347 | ObjectCreateRequest.ContentType = "application/json"; | 347 | ObjectCreateRequest.ContentType = "application/json"; |
348 | ObjectCreateRequest.Timeout = 10000; | 348 | ObjectCreateRequest.Timeout = 10000; |
349 | 349 | ||
350 | OSDMap args = new OSDMap(2); | 350 | OSDMap args = new OSDMap(2); |
351 | args["sog"] = OSD.FromString(sog.ToXmlString2()); | 351 | args["sog"] = OSD.FromString(sog.ToXmlString2()); |
352 | args["extra"] = OSD.FromString(sog.ExtraToXmlString()); | 352 | args["extra"] = OSD.FromString(sog.ExtraToXmlString()); |
353 | if (allowScriptCrossing) | 353 | if (allowScriptCrossing) |
354 | { | 354 | { |
355 | string state = sog.GetStateSnapshot(); | 355 | string state = sog.GetStateSnapshot(); |
356 | if (state.Length > 0) | 356 | if (state.Length > 0) |
357 | args["state"] = OSD.FromString(state); | 357 | args["state"] = OSD.FromString(state); |
358 | } | 358 | } |
359 | 359 | ||
360 | string strBuffer = ""; | 360 | string strBuffer = ""; |
361 | byte[] buffer = new byte[1]; | 361 | byte[] buffer = new byte[1]; |
362 | try | 362 | try |
363 | { | 363 | { |
364 | strBuffer = OSDParser.SerializeJsonString(args); | 364 | strBuffer = OSDParser.SerializeJsonString(args); |
365 | UTF8Encoding str = new UTF8Encoding(); | 365 | UTF8Encoding str = new UTF8Encoding(); |
366 | buffer = str.GetBytes(strBuffer); | 366 | buffer = str.GetBytes(strBuffer); |
367 | 367 | ||
368 | } | 368 | } |
369 | catch (Exception e) | 369 | catch (Exception e) |
370 | { | 370 | { |
371 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | 371 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); |
372 | // ignore. buffer will be empty, caller should check. | 372 | // ignore. buffer will be empty, caller should check. |
373 | } | 373 | } |
374 | 374 | ||
375 | Stream os = null; | 375 | Stream os = null; |
376 | try | 376 | try |
377 | { // send the Post | 377 | { // send the Post |
378 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send | 378 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send |
379 | os = ObjectCreateRequest.GetRequestStream(); | 379 | os = ObjectCreateRequest.GetRequestStream(); |
380 | os.Write(buffer, 0, strBuffer.Length); //Send it | 380 | os.Write(buffer, 0, strBuffer.Length); //Send it |
381 | os.Close(); | 381 | os.Close(); |
382 | m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); | 382 | m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); |
383 | } | 383 | } |
384 | //catch (WebException ex) | 384 | //catch (WebException ex) |
385 | catch | 385 | catch |
386 | { | 386 | { |
387 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); | 387 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); |
388 | 388 | ||
389 | return false; | 389 | return false; |
390 | } | 390 | } |
391 | 391 | ||
392 | // Let's wait for the response | 392 | // Let's wait for the response |
393 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | 393 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); |
394 | 394 | ||
395 | try | 395 | try |
396 | { | 396 | { |
397 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | 397 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); |
398 | if (webResponse == null) | 398 | if (webResponse == null) |
399 | { | 399 | { |
400 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | 400 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); |
401 | } | 401 | } |
402 | 402 | ||
403 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 403 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
404 | //reply = sr.ReadToEnd().Trim(); | 404 | //reply = sr.ReadToEnd().Trim(); |
405 | sr.ReadToEnd().Trim(); | 405 | sr.ReadToEnd().Trim(); |
406 | sr.Close(); | 406 | sr.Close(); |
407 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | 407 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); |
408 | 408 | ||
409 | } | 409 | } |
410 | catch (WebException ex) | 410 | catch (WebException ex) |
411 | { | 411 | { |
412 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | 412 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); |
413 | // ignore, really | 413 | // ignore, really |
414 | } | 414 | } |
415 | 415 | ||
416 | return true; | 416 | return true; |
417 | 417 | ||
418 | } | 418 | } |
419 | 419 | ||
420 | public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) | 420 | public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) |
421 | { | 421 | { |
422 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | 422 | ulong regionHandle = GetRegionHandle(region.RegionHandle); |
423 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; | 423 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; |
424 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); | 424 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); |
425 | 425 | ||
426 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); | 426 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); |
427 | ObjectCreateRequest.Method = "PUT"; | 427 | ObjectCreateRequest.Method = "PUT"; |
428 | ObjectCreateRequest.ContentType = "application/json"; | 428 | ObjectCreateRequest.ContentType = "application/json"; |
429 | ObjectCreateRequest.Timeout = 10000; | 429 | ObjectCreateRequest.Timeout = 10000; |
430 | 430 | ||
431 | OSDMap args = new OSDMap(2); | 431 | OSDMap args = new OSDMap(2); |
432 | args["userid"] = OSD.FromUUID(userID); | 432 | args["userid"] = OSD.FromUUID(userID); |
433 | args["itemid"] = OSD.FromUUID(itemID); | 433 | args["itemid"] = OSD.FromUUID(itemID); |
434 | 434 | ||
435 | string strBuffer = ""; | 435 | string strBuffer = ""; |
436 | byte[] buffer = new byte[1]; | 436 | byte[] buffer = new byte[1]; |
437 | try | 437 | try |
438 | { | 438 | { |
439 | strBuffer = OSDParser.SerializeJsonString(args); | 439 | strBuffer = OSDParser.SerializeJsonString(args); |
440 | UTF8Encoding str = new UTF8Encoding(); | 440 | UTF8Encoding str = new UTF8Encoding(); |
441 | buffer = str.GetBytes(strBuffer); | 441 | buffer = str.GetBytes(strBuffer); |
442 | 442 | ||
443 | } | 443 | } |
444 | catch (Exception e) | 444 | catch (Exception e) |
445 | { | 445 | { |
446 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | 446 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); |
447 | // ignore. buffer will be empty, caller should check. | 447 | // ignore. buffer will be empty, caller should check. |
448 | } | 448 | } |
449 | 449 | ||
450 | Stream os = null; | 450 | Stream os = null; |
451 | try | 451 | try |
452 | { // send the Post | 452 | { // send the Post |
453 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send | 453 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send |
454 | os = ObjectCreateRequest.GetRequestStream(); | 454 | os = ObjectCreateRequest.GetRequestStream(); |
455 | os.Write(buffer, 0, strBuffer.Length); //Send it | 455 | os.Write(buffer, 0, strBuffer.Length); //Send it |
456 | os.Close(); | 456 | os.Close(); |
457 | //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); | 457 | //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); |
458 | } | 458 | } |
459 | //catch (WebException ex) | 459 | //catch (WebException ex) |
460 | catch | 460 | catch |
461 | { | 461 | { |
462 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); | 462 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); |
463 | 463 | ||
464 | return false; | 464 | return false; |
465 | } | 465 | } |
466 | 466 | ||
467 | // Let's wait for the response | 467 | // Let's wait for the response |
468 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | 468 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); |
469 | 469 | ||
470 | try | 470 | try |
471 | { | 471 | { |
472 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | 472 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); |
473 | if (webResponse == null) | 473 | if (webResponse == null) |
474 | { | 474 | { |
475 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | 475 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); |
476 | } | 476 | } |
477 | 477 | ||
478 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 478 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
479 | sr.ReadToEnd().Trim(); | 479 | sr.ReadToEnd().Trim(); |
480 | sr.ReadToEnd().Trim(); | 480 | sr.ReadToEnd().Trim(); |
481 | sr.Close(); | 481 | sr.Close(); |
482 | 482 | ||
483 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | 483 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); |
484 | 484 | ||
485 | } | 485 | } |
486 | catch (WebException ex) | 486 | catch (WebException ex) |
487 | { | 487 | { |
488 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | 488 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); |
489 | // ignore, really | 489 | // ignore, really |
490 | } | 490 | } |
491 | 491 | ||
492 | return true; | 492 | return true; |
493 | 493 | ||
494 | } | 494 | } |
495 | 495 | ||
496 | public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) | 496 | public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) |
497 | { | 497 | { |
498 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; | 498 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; |
499 | //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); | 499 | //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); |
500 | 500 | ||
501 | WebRequest HelloNeighbourRequest = WebRequest.Create(uri); | 501 | WebRequest HelloNeighbourRequest = WebRequest.Create(uri); |
502 | HelloNeighbourRequest.Method = "POST"; | 502 | HelloNeighbourRequest.Method = "POST"; |
503 | HelloNeighbourRequest.ContentType = "application/json"; | 503 | HelloNeighbourRequest.ContentType = "application/json"; |
504 | HelloNeighbourRequest.Timeout = 10000; | 504 | HelloNeighbourRequest.Timeout = 10000; |
505 | 505 | ||
506 | // Fill it in | 506 | // Fill it in |
507 | OSDMap args = null; | 507 | OSDMap args = null; |
508 | try | 508 | try |
509 | { | 509 | { |
510 | args = thisRegion.PackRegionInfoData(); | 510 | args = thisRegion.PackRegionInfoData(); |
511 | } | 511 | } |
512 | catch (Exception e) | 512 | catch (Exception e) |
513 | { | 513 | { |
514 | m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); | 514 | m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); |
515 | } | 515 | } |
516 | // Add the regionhandle of the destination region | 516 | // Add the regionhandle of the destination region |
517 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | 517 | ulong regionHandle = GetRegionHandle(region.RegionHandle); |
518 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | 518 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); |
519 | 519 | ||
520 | string strBuffer = ""; | 520 | string strBuffer = ""; |
521 | byte[] buffer = new byte[1]; | 521 | byte[] buffer = new byte[1]; |
522 | try | 522 | try |
523 | { | 523 | { |
524 | strBuffer = OSDParser.SerializeJsonString(args); | 524 | strBuffer = OSDParser.SerializeJsonString(args); |
525 | UTF8Encoding str = new UTF8Encoding(); | 525 | UTF8Encoding str = new UTF8Encoding(); |
526 | buffer = str.GetBytes(strBuffer); | 526 | buffer = str.GetBytes(strBuffer); |
527 | 527 | ||
528 | } | 528 | } |
529 | catch (Exception e) | 529 | catch (Exception e) |
530 | { | 530 | { |
531 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); | 531 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); |
532 | // ignore. buffer will be empty, caller should check. | 532 | // ignore. buffer will be empty, caller should check. |
533 | } | 533 | } |
534 | 534 | ||
535 | Stream os = null; | 535 | Stream os = null; |
536 | try | 536 | try |
537 | { // send the Post | 537 | { // send the Post |
538 | HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send | 538 | HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send |
539 | os = HelloNeighbourRequest.GetRequestStream(); | 539 | os = HelloNeighbourRequest.GetRequestStream(); |
540 | os.Write(buffer, 0, strBuffer.Length); //Send it | 540 | os.Write(buffer, 0, strBuffer.Length); //Send it |
541 | os.Close(); | 541 | os.Close(); |
542 | //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); | 542 | //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); |
543 | } | 543 | } |
544 | //catch (WebException ex) | 544 | //catch (WebException ex) |
545 | catch | 545 | catch |
546 | { | 546 | { |
547 | //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); | 547 | //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); |
548 | 548 | ||
549 | return false; | 549 | return false; |
550 | } | 550 | } |
551 | 551 | ||
552 | // Let's wait for the response | 552 | // Let's wait for the response |
553 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); | 553 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); |
554 | 554 | ||
555 | try | 555 | try |
556 | { | 556 | { |
557 | WebResponse webResponse = HelloNeighbourRequest.GetResponse(); | 557 | WebResponse webResponse = HelloNeighbourRequest.GetResponse(); |
558 | if (webResponse == null) | 558 | if (webResponse == null) |
559 | { | 559 | { |
560 | m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); | 560 | m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); |
561 | } | 561 | } |
562 | 562 | ||
563 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 563 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
564 | //reply = sr.ReadToEnd().Trim(); | 564 | //reply = sr.ReadToEnd().Trim(); |
565 | sr.ReadToEnd().Trim(); | 565 | sr.ReadToEnd().Trim(); |
566 | sr.Close(); | 566 | sr.Close(); |
567 | //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); | 567 | //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); |
568 | 568 | ||
569 | } | 569 | } |
570 | catch (WebException ex) | 570 | catch (WebException ex) |
571 | { | 571 | { |
572 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); | 572 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); |
573 | // ignore, really | 573 | // ignore, really |
574 | } | 574 | } |
575 | 575 | ||
576 | return true; | 576 | return true; |
577 | 577 | ||
578 | } | 578 | } |
579 | 579 | ||
580 | #region Hyperlinks | 580 | #region Hyperlinks |
581 | 581 | ||
582 | public virtual ulong GetRegionHandle(ulong handle) | 582 | public virtual ulong GetRegionHandle(ulong handle) |
583 | { | 583 | { |
584 | return handle; | 584 | return handle; |
585 | } | 585 | } |
586 | 586 | ||
587 | public virtual bool IsHyperlink(ulong handle) | 587 | public virtual bool IsHyperlink(ulong handle) |
588 | { | 588 | { |
589 | return false; | 589 | return false; |
590 | } | 590 | } |
591 | 591 | ||
592 | public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) | 592 | public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) |
593 | { | 593 | { |
594 | } | 594 | } |
595 | 595 | ||
596 | public virtual void AdjustUserInformation(AgentCircuitData aCircuit) | 596 | public virtual void AdjustUserInformation(AgentCircuitData aCircuit) |
597 | { | 597 | { |
598 | } | 598 | } |
599 | 599 | ||
600 | #endregion /* Hyperlinks */ | 600 | #endregion /* Hyperlinks */ |
601 | 601 | ||
602 | public static OSDMap GetOSDMap(string data) | 602 | public static OSDMap GetOSDMap(string data) |
603 | { | 603 | { |
604 | OSDMap args = null; | 604 | OSDMap args = null; |
605 | try | 605 | try |
606 | { | 606 | { |
607 | OSD buffer; | 607 | OSD buffer; |
608 | // We should pay attention to the content-type, but let's assume we know it's Json | 608 | // We should pay attention to the content-type, but let's assume we know it's Json |
609 | buffer = OSDParser.DeserializeJson(data); | 609 | buffer = OSDParser.DeserializeJson(data); |
610 | if (buffer.Type == OSDType.Map) | 610 | if (buffer.Type == OSDType.Map) |
611 | { | 611 | { |
612 | args = (OSDMap)buffer; | 612 | args = (OSDMap)buffer; |
613 | return args; | 613 | return args; |
614 | } | 614 | } |
615 | else | 615 | else |
616 | { | 616 | { |
617 | // uh? | 617 | // uh? |
618 | System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); | 618 | System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); |
619 | return null; | 619 | return null; |
620 | } | 620 | } |
621 | } | 621 | } |
622 | catch (Exception ex) | 622 | catch (Exception ex) |
623 | { | 623 | { |
624 | System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); | 624 | System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); |
625 | return null; | 625 | return null; |
626 | } | 626 | } |
627 | } | 627 | } |
628 | 628 | ||
629 | 629 | ||
630 | } | 630 | } |
631 | } | 631 | } |
diff --git a/OpenSim/Framework/ISceneObject.cs b/OpenSim/Framework/ISceneObject.cs index 87dcc2d..c327b05 100644 --- a/OpenSim/Framework/ISceneObject.cs +++ b/OpenSim/Framework/ISceneObject.cs | |||
@@ -1,42 +1,42 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenMetaverse; | 28 | using OpenMetaverse; |
29 | 29 | ||
30 | namespace OpenSim.Framework | 30 | namespace OpenSim.Framework |
31 | { | 31 | { |
32 | public interface ISceneObject | 32 | public interface ISceneObject |
33 | { | 33 | { |
34 | UUID UUID { get; } | 34 | UUID UUID { get; } |
35 | ISceneObject CloneForNewScene(); | 35 | ISceneObject CloneForNewScene(); |
36 | string ToXmlString2(); | 36 | string ToXmlString2(); |
37 | string ExtraToXmlString(); | 37 | string ExtraToXmlString(); |
38 | void ExtraFromXmlString(string xmlstr); | 38 | void ExtraFromXmlString(string xmlstr); |
39 | string GetStateSnapshot(); | 39 | string GetStateSnapshot(); |
40 | void SetState(string xmlstr, UUID regionID); | 40 | void SetState(string xmlstr, UUID regionID); |
41 | } | 41 | } |
42 | } | 42 | } |