aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
authorMW2007-12-01 18:49:17 +0000
committerMW2007-12-01 18:49:17 +0000
commit5df851761aa796cba70a3b6d8b36d119502c1de2 (patch)
tree4cab0f2d6ea32a6cfb280d74583d8ffce7331c26 /OpenSim/Framework/Servers
parentAttempt to fix mantis issue # 65, seems like it is a race condition between t... (diff)
downloadopensim-SC_OLD-5df851761aa796cba70a3b6d8b36d119502c1de2.zip
opensim-SC_OLD-5df851761aa796cba70a3b6d8b36d119502c1de2.tar.gz
opensim-SC_OLD-5df851761aa796cba70a3b6d8b36d119502c1de2.tar.bz2
opensim-SC_OLD-5df851761aa796cba70a3b6d8b36d119502c1de2.tar.xz
Initial working Grid Inventory server. Only been tested on a very small grid, so likely to have problems on a larger grid with more people?
To use , both the user server and Inventory server need to be running this latest revision. (older regions should be able to still be used, just the user won't have inventory on them). Also and HERE IS THE BIG BREAK ISSUE, currently, so that the initial inventory details for a user are added to the inventory db , you need to recreate the accounts using the user server "create user" feature. It should be quite easy to manual populate the inventory database instead but I someone else will need to look into that) Also I've only tested using SQLite as the database provider, there is a Mysql inventory provider but I don't know if it works (SQLite is set as default, so you will need to change it in the inventory server config.xml)
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/RestObjectPoster.cs92
1 files changed, 92 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/RestObjectPoster.cs b/OpenSim/Framework/Servers/RestObjectPoster.cs
index b77cbcc..07095f3 100644
--- a/OpenSim/Framework/Servers/RestObjectPoster.cs
+++ b/OpenSim/Framework/Servers/RestObjectPoster.cs
@@ -8,8 +8,11 @@ using System.Xml.Serialization;
8 8
9namespace OpenSim.Framework.Servers 9namespace OpenSim.Framework.Servers
10{ 10{
11 public delegate void ReturnResponse<T>(T reponse);
12
11 public class RestObjectPoster 13 public class RestObjectPoster
12 { 14 {
15
13 public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj) 16 public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
14 { 17 {
15 Type type = typeof(TRequest); 18 Type type = typeof(TRequest);
@@ -46,4 +49,93 @@ namespace OpenSim.Framework.Servers
46 } 49 }
47 } 50 }
48 } 51 }
52
53 public class RestObjectPosterResponse<TResponse>
54 {
55 public ReturnResponse<TResponse> ReturnResponseVal;
56
57 public void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
58 {
59 Type type = typeof(TRequest);
60
61 WebRequest request = WebRequest.Create(requestUrl);
62 request.Method = "POST";
63 request.ContentType = "text/xml";
64
65 MemoryStream buffer = new MemoryStream();
66
67 XmlWriterSettings settings = new XmlWriterSettings();
68 settings.Encoding = Encoding.UTF8;
69
70 using (XmlWriter writer = XmlWriter.Create(buffer, settings))
71 {
72 XmlSerializer serializer = new XmlSerializer(type);
73 serializer.Serialize(writer, obj);
74 writer.Flush();
75 }
76
77 int length = (int)buffer.Length;
78 request.ContentLength = length;
79
80 Stream requestStream = request.GetRequestStream();
81 requestStream.Write(buffer.ToArray(), 0, length);
82 IAsyncResult result = request.BeginGetResponse(AsyncCallback, request);
83 }
84
85 private void AsyncCallback(IAsyncResult result)
86 {
87 WebRequest request = (WebRequest)result.AsyncState;
88 using (WebResponse resp = request.EndGetResponse(result))
89 {
90 TResponse deserial;
91 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
92 deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream());
93
94 if (deserial != null && ReturnResponseVal != null)
95 {
96 ReturnResponseVal(deserial);
97 }
98 }
99 }
100 }
101
102 public class SyncRestObjectPoster
103 {
104
105 public static TResponse BeginPostObject<TRequest, TResponse>(string requestUrl, TRequest obj)
106 {
107 Type type = typeof(TRequest);
108
109 WebRequest request = WebRequest.Create(requestUrl);
110 request.Method = "POST";
111 request.ContentType = "text/xml";
112
113 MemoryStream buffer = new MemoryStream();
114
115 XmlWriterSettings settings = new XmlWriterSettings();
116 settings.Encoding = Encoding.UTF8;
117
118 using (XmlWriter writer = XmlWriter.Create(buffer, settings))
119 {
120 XmlSerializer serializer = new XmlSerializer(type);
121 serializer.Serialize(writer, obj);
122 writer.Flush();
123 }
124
125 int length = (int)buffer.Length;
126 request.ContentLength = length;
127
128 Stream requestStream = request.GetRequestStream();
129 requestStream.Write(buffer.ToArray(), 0, length);
130 TResponse deserial = default(TResponse);
131 using (WebResponse resp = request.GetResponse())
132 {
133
134 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
135 deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream());
136 }
137 return deserial;
138 }
139
140 }
49} \ No newline at end of file 141} \ No newline at end of file