diff --git a/ln.http.resources.csproj b/ln.http.resources.csproj
index b1aaca7..39fce06 100644
--- a/ln.http.resources.csproj
+++ b/ln.http.resources.csproj
@@ -50,6 +50,7 @@
+
@@ -73,6 +74,7 @@
+
diff --git a/reflection/Reflector.cs b/reflection/Reflector.cs
index 01830e3..66665db 100644
--- a/reflection/Reflector.cs
+++ b/reflection/Reflector.cs
@@ -4,6 +4,7 @@ using System.Reflection;
using ln.http.exceptions;
using System.IO;
using System.Text;
+using System.ComponentModel;
namespace ln.http.resources.reflection
{
public class Reflector
@@ -55,6 +56,10 @@ namespace ln.http.resources.reflection
{
currentValue = properties[next].GetValue(currentValue);
}
+ else if (methods.ContainsKey(next))
+ {
+ currentValue = InvokeMethod(next, httpRequest, currentValue);
+ }
else
{
throw new KeyNotFoundException(next);
@@ -93,6 +98,31 @@ namespace ln.http.resources.reflection
return currentValue;
}
+ object InvokeMethod(string methodName, HttpRequest httpRequest, object currentValue)
+ {
+ MethodInfo methodInfo = methods[methodName];
+ ParameterInfo[] parameterInfos = methodInfo.GetParameters();
+ object[] parameters = new object[parameterInfos.Length];
+
+ for (int n=0;n GetResources()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override HttpResponse GetResponse(HttpRequest httpRequest)
+ {
+ MemoryStream buffer = null;
+
+ WebSocket webSocket = new WebSocket(httpRequest);
+ webSocket.WebSocketEvent += (WebSocket sender, WebSocketEventArgs e) => {
+ switch (e.EventType)
+ {
+ case WebSocketEventType.MESSAGE:
+ if (buffer == null)
+ buffer = new MemoryStream();
+
+ buffer.WriteBytes(e.BinaryMessage);
+
+ if (e.Frame.FIN)
+ {
+ WebSocketResourceRequestContext context = new WebSocketResourceRequestContext(
+ this,
+ webSocket,
+ httpRequest
+ );
+
+ if (e.IsBinary)
+ MessageReceived(context, buffer.ToArray());
+ else
+ MessageReceived(context, Encoding.UTF8.GetString(buffer.ToArray()));
+
+ buffer.Dispose();
+ buffer = null;
+ }
+
+ break;
+ }
+ };
+
+ try
+ {
+ Connection(this, webSocket, WSREvent.CONNECT);
+ webSocket.Run();
+ } catch (Exception e)
+ {
+ Logging.Log(e);
+ }
+ Connection(this, webSocket, WSREvent.CLOSE);
+
+ httpRequest.GetConnectionStream().Close();
+ return null;
+ }
+
+ public override void RemoveResource(Resource resource)
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual void MessageReceived(WebSocketResourceRequestContext requestContext,byte[] binaryMessage)
+ {
+ Logging.Log(LogLevel.WARNING, "WebSocketResource: received unhandled binary message: {0}",BitConverter.ToString(binaryMessage));
+ }
+ public virtual void MessageReceived(WebSocketResourceRequestContext requestContext, String textMessage)
+ {
+ Logging.Log(LogLevel.WARNING, "WebSocketResource: received unhandled text message: {0}", textMessage);
+ }
+
+ }
+}