aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs106
-rw-r--r--bin/OpenSim.ini.example5
2 files changed, 108 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index f383bad..fe027c6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -26,9 +26,10 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
29using System.Collections; 30using System.Collections;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using System.Net; 32using System.Xml;
32using System.Reflection; 33using System.Reflection;
33using log4net; 34using log4net;
34using Nini.Config; 35using Nini.Config;
@@ -36,17 +37,38 @@ using Nwc.XmlRpc;
36using OpenMetaverse; 37using OpenMetaverse;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
39
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using OpenSim.Server.Base;
44using OpenSim.Framework.Servers.HttpServer;
45using log4net;
43 46
44namespace OpenSim.Region.CoreModules.Avatar.Friends 47namespace OpenSim.Region.CoreModules.Avatar.Friends
45{ 48{
46 public class FriendsModule : ISharedRegionModule, IFriendsModule 49 public class FriendsModule : BaseStreamHandler, ISharedRegionModule, IFriendsModule
47 { 50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 protected int m_Port = 0;
54
55 public FriendsModule()
56 : base("POST", "/friends")
57 {
58 }
59
48 public void Initialise(IConfigSource config) 60 public void Initialise(IConfigSource config)
49 { 61 {
62 IConfig friendsConfig = config.Configs["Friends"];
63 if (friendsConfig != null)
64 {
65 m_Port = friendsConfig.GetInt("Port", m_Port);
66 }
67
68 IHttpServer server = MainServer.GetHttpServer((uint)m_Port);
69
70 server.AddStreamHandler(this);
71
50 } 72 }
51 73
52 public void PostInitialise() 74 public void PostInitialise()
@@ -69,6 +91,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
69 { 91 {
70 } 92 }
71 93
94 public override byte[] Handle(string path, Stream requestData,
95 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
96 {
97 StreamReader sr = new StreamReader(requestData);
98 string body = sr.ReadToEnd();
99 sr.Close();
100 body = body.Trim();
101
102 m_log.DebugFormat("[XXX]: query String: {0}", body);
103
104 try
105 {
106 Dictionary<string, object> request =
107 ServerUtils.ParseQueryString(body);
108
109 if (!request.ContainsKey("METHOD"))
110 return FailureResult();
111
112 string method = request["METHOD"].ToString();
113 request.Remove("METHOD");
114
115 switch (method)
116 {
117 case "TEST":
118 break;
119 }
120 }
121 catch (Exception e)
122 {
123 m_log.Debug("[FRIENDS]: Exception {0}" + e.ToString());
124 }
125
126 return FailureResult();
127 }
128
72 public string Name 129 public string Name
73 { 130 {
74 get { return "FriendsModule"; } 131 get { return "FriendsModule"; }
@@ -87,5 +144,48 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
87 { 144 {
88 return 1; 145 return 1;
89 } 146 }
147
148 private byte[] FailureResult()
149 {
150 return BoolResult(false);
151 }
152
153 private byte[] SuccessResult()
154 {
155 return BoolResult(true);
156 }
157
158 private byte[] BoolResult(bool value)
159 {
160 XmlDocument doc = new XmlDocument();
161
162 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
163 "", "");
164
165 doc.AppendChild(xmlnode);
166
167 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
168 "");
169
170 doc.AppendChild(rootElement);
171
172 XmlElement result = doc.CreateElement("", "RESULT", "");
173 result.AppendChild(doc.CreateTextNode(value.ToString()));
174
175 rootElement.AppendChild(result);
176
177 return DocToBytes(doc);
178 }
179
180 private byte[] DocToBytes(XmlDocument doc)
181 {
182 MemoryStream ms = new MemoryStream();
183 XmlTextWriter xw = new XmlTextWriter(ms, null);
184 xw.Formatting = Formatting.Indented;
185 doc.WriteTo(xw);
186 xw.Flush();
187
188 return ms.ToArray();
189 }
90 } 190 }
91} 191}
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index dd487b7..7eea3b4 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -1316,3 +1316,8 @@
1316 1316
1317 ;XmlRpcRouterModule = "XmlRpcRouterModule" 1317 ;XmlRpcRouterModule = "XmlRpcRouterModule"
1318 ;XmlRpcPort = 20800 1318 ;XmlRpcPort = 20800
1319
1320[Friends]
1321 ; The port the friendslist interregion comms will listen on
1322 ; Defaults to the simulator's TCP port
1323 ;Port = 0