aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs34
-rw-r--r--OpenSim/Framework/Servers/BaseStreamHandler.cs21
-rw-r--r--OpenSim/Framework/Servers/BinaryStreamHandler.cs17
-rw-r--r--OpenSim/Framework/Servers/CheckSumServer.cs4
-rw-r--r--OpenSim/Framework/Servers/IStreamHandler.cs13
-rw-r--r--OpenSim/Framework/Servers/RestMethod.cs4
-rw-r--r--OpenSim/Framework/Servers/RestStreamHandler.cs14
-rw-r--r--OpenSim/Framework/Servers/UDPServerBase.cs11
-rw-r--r--OpenSim/Framework/Servers/XmlRpcMethod.cs4
9 files changed, 55 insertions, 67 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 179a651..52d2a2c 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -31,11 +31,10 @@ using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Net; 32using System.Net;
33using System.Text; 33using System.Text;
34using System.Text.RegularExpressions;
35using System.Threading; 34using System.Threading;
35using System.Xml;
36using Nwc.XmlRpc; 36using Nwc.XmlRpc;
37using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
38using System.Xml;
39 38
40namespace OpenSim.Framework.Servers 39namespace OpenSim.Framework.Servers
41{ 40{
@@ -50,7 +49,7 @@ namespace OpenSim.Framework.Servers
50 49
51 public int Port 50 public int Port
52 { 51 {
53 get { return m_port; } 52 get { return m_port; }
54 } 53 }
55 54
56 public BaseHttpServer(int port) 55 public BaseHttpServer(int port)
@@ -58,11 +57,11 @@ namespace OpenSim.Framework.Servers
58 m_port = port; 57 m_port = port;
59 } 58 }
60 59
61 public void AddStreamHandler( IStreamHandler handler) 60 public void AddStreamHandler(IStreamHandler handler)
62 { 61 {
63 string httpMethod = handler.HttpMethod; 62 string httpMethod = handler.HttpMethod;
64 string path = handler.Path; 63 string path = handler.Path;
65 64
66 string handlerKey = GetHandlerKey(httpMethod, path); 65 string handlerKey = GetHandlerKey(httpMethod, path);
67 m_streamHandlers.Add(handlerKey, handler); 66 m_streamHandlers.Add(handlerKey, handler);
68 } 67 }
@@ -74,9 +73,9 @@ namespace OpenSim.Framework.Servers
74 73
75 public bool AddXmlRPCHandler(string method, XmlRpcMethod handler) 74 public bool AddXmlRPCHandler(string method, XmlRpcMethod handler)
76 { 75 {
77 if (!this.m_rpcHandlers.ContainsKey(method)) 76 if (!m_rpcHandlers.ContainsKey(method))
78 { 77 {
79 this.m_rpcHandlers.Add(method, handler); 78 m_rpcHandlers.Add(method, handler);
80 return true; 79 return true;
81 } 80 }
82 81
@@ -87,7 +86,7 @@ namespace OpenSim.Framework.Servers
87 86
88 public virtual void HandleRequest(Object stateinfo) 87 public virtual void HandleRequest(Object stateinfo)
89 { 88 {
90 HttpListenerContext context = (HttpListenerContext)stateinfo; 89 HttpListenerContext context = (HttpListenerContext) stateinfo;
91 90
92 HttpListenerRequest request = context.Request; 91 HttpListenerRequest request = context.Request;
93 HttpListenerResponse response = context.Response; 92 HttpListenerResponse response = context.Response;
@@ -96,11 +95,11 @@ namespace OpenSim.Framework.Servers
96 response.SendChunked = false; 95 response.SendChunked = false;
97 96
98 string path = request.RawUrl; 97 string path = request.RawUrl;
99 string handlerKey = GetHandlerKey( request.HttpMethod, path ); 98 string handlerKey = GetHandlerKey(request.HttpMethod, path);
100 99
101 IStreamHandler streamHandler; 100 IStreamHandler streamHandler;
102 101
103 if (TryGetStreamHandler( handlerKey, out streamHandler)) 102 if (TryGetStreamHandler(handlerKey, out streamHandler))
104 { 103 {
105 byte[] buffer = streamHandler.Handle(path, request.InputStream); 104 byte[] buffer = streamHandler.Handle(path, request.InputStream);
106 request.InputStream.Close(); 105 request.InputStream.Close();
@@ -159,11 +158,11 @@ namespace OpenSim.Framework.Servers
159 158
160 try 159 try
161 { 160 {
162 xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); 161 xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody);
163 } 162 }
164 catch ( XmlException e ) 163 catch (XmlException e)
165 { 164 {
166 responseString = String.Format( "XmlException:\n{0}",e.Message ); 165 responseString = String.Format("XmlException:\n{0}", e.Message);
167 } 166 }
168 167
169 if (xmlRprcRequest != null) 168 if (xmlRprcRequest != null)
@@ -173,7 +172,7 @@ namespace OpenSim.Framework.Servers
173 XmlRpcResponse xmlRpcResponse; 172 XmlRpcResponse xmlRpcResponse;
174 173
175 XmlRpcMethod method; 174 XmlRpcMethod method;
176 if (this.m_rpcHandlers.TryGetValue(methodName, out method)) 175 if (m_rpcHandlers.TryGetValue(methodName, out method))
177 { 176 {
178 xmlRpcResponse = method(xmlRprcRequest); 177 xmlRpcResponse = method(xmlRprcRequest);
179 } 178 }
@@ -181,7 +180,8 @@ namespace OpenSim.Framework.Servers
181 { 180 {
182 xmlRpcResponse = new XmlRpcResponse(); 181 xmlRpcResponse = new XmlRpcResponse();
183 Hashtable unknownMethodError = new Hashtable(); 182 Hashtable unknownMethodError = new Hashtable();
184 unknownMethodError["reason"] = "XmlRequest"; ; 183 unknownMethodError["reason"] = "XmlRequest";
184 ;
185 unknownMethodError["message"] = "Unknown Rpc Request [" + methodName + "]"; 185 unknownMethodError["message"] = "Unknown Rpc Request [" + methodName + "]";
186 unknownMethodError["login"] = "false"; 186 unknownMethodError["login"] = "false";
187 xmlRpcResponse.Value = unknownMethodError; 187 xmlRpcResponse.Value = unknownMethodError;
@@ -249,4 +249,4 @@ namespace OpenSim.Framework.Servers
249 m_streamHandlers.Remove(GetHandlerKey(httpMethod, path)); 249 m_streamHandlers.Remove(GetHandlerKey(httpMethod, path));
250 } 250 }
251 } 251 }
252} 252} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/BaseStreamHandler.cs b/OpenSim/Framework/Servers/BaseStreamHandler.cs
index 4b609c3..cd99183 100644
--- a/OpenSim/Framework/Servers/BaseStreamHandler.cs
+++ b/OpenSim/Framework/Servers/BaseStreamHandler.cs
@@ -26,37 +26,36 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.IO; 29using System.IO;
33 30
34namespace OpenSim.Framework.Servers 31namespace OpenSim.Framework.Servers
35{ 32{
36 public abstract class BaseStreamHandler : IStreamHandler 33 public abstract class BaseStreamHandler : IStreamHandler
37 { 34 {
38 virtual public string ContentType 35 public virtual string ContentType
39 { 36 {
40 get { return "application/xml"; } 37 get { return "application/xml"; }
41 } 38 }
42 39
43 private string m_httpMethod; 40 private string m_httpMethod;
44 virtual public string HttpMethod 41
42 public virtual string HttpMethod
45 { 43 {
46 get { return m_httpMethod; } 44 get { return m_httpMethod; }
47 } 45 }
48 46
49 private string m_path; 47 private string m_path;
50 virtual public string Path 48
49 public virtual string Path
51 { 50 {
52 get { return m_path; } 51 get { return m_path; }
53 } 52 }
54 53
55 protected string GetParam( string path ) 54 protected string GetParam(string path)
56 { 55 {
57 return path.Substring( m_path.Length ); 56 return path.Substring(m_path.Length);
58 } 57 }
59 58
60 public abstract byte[] Handle(string path, Stream request); 59 public abstract byte[] Handle(string path, Stream request);
61 60
62 protected BaseStreamHandler(string httpMethod, string path) 61 protected BaseStreamHandler(string httpMethod, string path)
@@ -65,4 +64,4 @@ namespace OpenSim.Framework.Servers
65 m_path = path; 64 m_path = path;
66 } 65 }
67 } 66 }
68} 67} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/BinaryStreamHandler.cs
index 4cc6fc7..65fa3c9 100644
--- a/OpenSim/Framework/Servers/BinaryStreamHandler.cs
+++ b/OpenSim/Framework/Servers/BinaryStreamHandler.cs
@@ -26,10 +26,8 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.IO; 29using System.IO;
30using System.Text;
33 31
34namespace OpenSim.Framework.Servers 32namespace OpenSim.Framework.Servers
35{ 33{
@@ -37,14 +35,14 @@ namespace OpenSim.Framework.Servers
37 35
38 public class BinaryStreamHandler : BaseStreamHandler 36 public class BinaryStreamHandler : BaseStreamHandler
39 { 37 {
40 BinaryMethod m_method; 38 private BinaryMethod m_method;
41 39
42 override public byte[] Handle(string path, Stream request) 40 public override byte[] Handle(string path, Stream request)
43 { 41 {
44 byte[] data = ReadFully(request); 42 byte[] data = ReadFully(request);
45 string param = GetParam(path); 43 string param = GetParam(path);
46 string responseString = m_method(data, path, param); 44 string responseString = m_method(data, path, param);
47 45
48 return Encoding.UTF8.GetBytes(responseString); 46 return Encoding.UTF8.GetBytes(responseString);
49 } 47 }
50 48
@@ -67,11 +65,10 @@ namespace OpenSim.Framework.Servers
67 { 65 {
68 return ms.ToArray(); 66 return ms.ToArray();
69 } 67 }
70 68
71 ms.Write(buffer, 0, read); 69 ms.Write(buffer, 0, read);
72 } 70 }
73 } 71 }
74 } 72 }
75 } 73 }
76 74} \ No newline at end of file
77}
diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs
index 62e5ea0..ef4c0ee 100644
--- a/OpenSim/Framework/Servers/CheckSumServer.cs
+++ b/OpenSim/Framework/Servers/CheckSumServer.cs
@@ -26,7 +26,8 @@
26* 26*
27*/ 27*/
28namespace OpenSim.Framework.Servers 28namespace OpenSim.Framework.Servers
29{/* 29{
30 /*
30 public class CheckSumServer : UDPServerBase 31 public class CheckSumServer : UDPServerBase
31 { 32 {
32 //protected ConsoleBase m_log; 33 //protected ConsoleBase m_log;
@@ -123,5 +124,4 @@ namespace OpenSim.Framework.Servers
123 } 124 }
124 * } 125 * }
125 */ 126 */
126
127} \ No newline at end of file 127} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/IStreamHandler.cs b/OpenSim/Framework/Servers/IStreamHandler.cs
index d97b37f..d674172 100644
--- a/OpenSim/Framework/Servers/IStreamHandler.cs
+++ b/OpenSim/Framework/Servers/IStreamHandler.cs
@@ -26,9 +26,6 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.IO; 29using System.IO;
33 30
34namespace OpenSim.Framework.Servers 31namespace OpenSim.Framework.Servers
@@ -36,15 +33,15 @@ namespace OpenSim.Framework.Servers
36 public interface IStreamHandler 33 public interface IStreamHandler
37 { 34 {
38 // Handle request stream, return byte array 35 // Handle request stream, return byte array
39 byte[] Handle(string path, Stream request ); 36 byte[] Handle(string path, Stream request);
40 37
41 // Return response content type 38 // Return response content type
42 string ContentType { get; } 39 string ContentType { get; }
43 40
44 // Return required http method 41 // Return required http method
45 string HttpMethod { get;} 42 string HttpMethod { get; }
46 43
47 // Return path 44 // Return path
48 string Path { get; } 45 string Path { get; }
49 } 46 }
50} 47} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/RestMethod.cs b/OpenSim/Framework/Servers/RestMethod.cs
index 80c6451..83f9e71 100644
--- a/OpenSim/Framework/Servers/RestMethod.cs
+++ b/OpenSim/Framework/Servers/RestMethod.cs
@@ -27,5 +27,5 @@
27*/ 27*/
28namespace OpenSim.Framework.Servers 28namespace OpenSim.Framework.Servers
29{ 29{
30 public delegate string RestMethod( string request, string path, string param ); 30 public delegate string RestMethod(string request, string path, string param);
31} 31} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/RestStreamHandler.cs b/OpenSim/Framework/Servers/RestStreamHandler.cs
index 1b1876e..0450387 100644
--- a/OpenSim/Framework/Servers/RestStreamHandler.cs
+++ b/OpenSim/Framework/Servers/RestStreamHandler.cs
@@ -26,18 +26,16 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.IO; 29using System.IO;
30using System.Text;
33 31
34namespace OpenSim.Framework.Servers 32namespace OpenSim.Framework.Servers
35{ 33{
36 public class RestStreamHandler : BaseStreamHandler 34 public class RestStreamHandler : BaseStreamHandler
37 { 35 {
38 RestMethod m_restMethod; 36 private RestMethod m_restMethod;
39 37
40 override public byte[] Handle(string path, Stream request ) 38 public override byte[] Handle(string path, Stream request)
41 { 39 {
42 Encoding encoding = Encoding.UTF8; 40 Encoding encoding = Encoding.UTF8;
43 StreamReader streamReader = new StreamReader(request, encoding); 41 StreamReader streamReader = new StreamReader(request, encoding);
@@ -46,14 +44,14 @@ namespace OpenSim.Framework.Servers
46 streamReader.Close(); 44 streamReader.Close();
47 45
48 string param = GetParam(path); 46 string param = GetParam(path);
49 string responseString = m_restMethod(requestBody, path, param ); 47 string responseString = m_restMethod(requestBody, path, param);
50 48
51 return Encoding.UTF8.GetBytes(responseString); 49 return Encoding.UTF8.GetBytes(responseString);
52 } 50 }
53 51
54 public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path ) 52 public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base(httpMethod, path)
55 { 53 {
56 m_restMethod = restMethod; 54 m_restMethod = restMethod;
57 } 55 }
58 } 56 }
59} 57} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/UDPServerBase.cs b/OpenSim/Framework/Servers/UDPServerBase.cs
index 8fc32ff..017168f 100644
--- a/OpenSim/Framework/Servers/UDPServerBase.cs
+++ b/OpenSim/Framework/Servers/UDPServerBase.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Framework.Servers
51 protected virtual void OnReceivedData(IAsyncResult result) 51 protected virtual void OnReceivedData(IAsyncResult result)
52 { 52 {
53 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); 53 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
54 epSender = (EndPoint)ipeSender; 54 epSender = (EndPoint) ipeSender;
55 Packet packet = null; 55 Packet packet = null;
56 int numBytes = Server.EndReceiveFrom(result, ref epSender); 56 int numBytes = Server.EndReceiveFrom(result, ref epSender);
57 int packetEnd = numBytes - 1; 57 int packetEnd = numBytes - 1;
@@ -67,21 +67,18 @@ namespace OpenSim.Framework.Servers
67 67
68 public virtual void ServerListener() 68 public virtual void ServerListener()
69 { 69 {
70
71 ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort); 70 ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort);
72 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); 71 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
73 Server.Bind(ServerIncoming); 72 Server.Bind(ServerIncoming);
74 73
75 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); 74 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
76 epSender = (EndPoint)ipeSender; 75 epSender = (EndPoint) ipeSender;
77 ReceivedData = new AsyncCallback(this.OnReceivedData); 76 ReceivedData = new AsyncCallback(OnReceivedData);
78 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 77 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
79 } 78 }
80 79
81 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) 80 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
82 { 81 {
83
84 } 82 }
85 } 83 }
86} 84} \ No newline at end of file
87
diff --git a/OpenSim/Framework/Servers/XmlRpcMethod.cs b/OpenSim/Framework/Servers/XmlRpcMethod.cs
index ef14cf6..c3817ca 100644
--- a/OpenSim/Framework/Servers/XmlRpcMethod.cs
+++ b/OpenSim/Framework/Servers/XmlRpcMethod.cs
@@ -29,5 +29,5 @@ using Nwc.XmlRpc;
29 29
30namespace OpenSim.Framework.Servers 30namespace OpenSim.Framework.Servers
31{ 31{
32 public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request ); 32 public delegate XmlRpcResponse XmlRpcMethod(XmlRpcRequest request);
33} 33} \ No newline at end of file