mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
* Moved SendNameReply to ClientView
* Removed unused LoginService * Minor renames on BinaryStreamHandler
This commit is contained in:
@@ -5,27 +5,28 @@ using System.IO;
|
||||
|
||||
namespace OpenSim.Framework.Servers
|
||||
{
|
||||
public delegate string BinaryMethod(byte[] data, string path, string param);
|
||||
|
||||
public class BinaryStreamHandler : BaseStreamHandler
|
||||
{
|
||||
BinaryMethod m_restMethod;
|
||||
BinaryMethod m_method;
|
||||
|
||||
override public byte[] Handle(string path, Stream request)
|
||||
{
|
||||
byte[] data = ReadFully(request);
|
||||
string param = GetParam(path);
|
||||
string responseString = m_restMethod(data, path, param);
|
||||
|
||||
string responseString = m_method(data, path, param);
|
||||
|
||||
return Encoding.UTF8.GetBytes(responseString);
|
||||
}
|
||||
|
||||
public BinaryStreamHandler(string httpMethod, string path, BinaryMethod restMethod)
|
||||
public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod)
|
||||
: base(httpMethod, path)
|
||||
{
|
||||
m_restMethod = restMethod;
|
||||
m_method = binaryMethod;
|
||||
}
|
||||
|
||||
public byte[] ReadFully(Stream stream)
|
||||
private byte[] ReadFully(Stream stream)
|
||||
{
|
||||
byte[] buffer = new byte[32768];
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
@@ -33,11 +34,15 @@ namespace OpenSim.Framework.Servers
|
||||
while (true)
|
||||
{
|
||||
int read = stream.Read(buffer, 0, buffer.Length);
|
||||
|
||||
if (read <= 0)
|
||||
{
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
ms.Write(buffer, 0, read);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user