public void RaiseIncomingData(WebServerProvider sender, IncomingDataArguments args) { if (IncomingData != null) { IncomingData(sender, args); } }
public void RaiseIncomingData(WebServerProvider sender, IncomingDataArguments args) { // jsc needs to take care of this on its own! // as we cannot call local event from an anonymous delegate it seems if (IncomingData != null) IncomingData(sender, args); }
public void RaiseIncomingData(WebServerProvider sender, IncomingDataArguments args) { // jsc needs to take care of this on its own! // as we cannot call local event from an anonymous delegate it seems if (IncomingData != null) { IncomingData(sender, args); } }
private void webServerComponent1_IncomingData(WebServerProvider sender, IncomingDataArguments a) { // we are probably on a wrong thread here // let the server know real fast what our log looks like // so thet he could send it to the client //this.History.AppendLine(a.PathAndQuery); //Console.WriteLine(a.PathAndQuery); a.PathAndQuery = a.PathAndQuery.Chop(outgoingMessages1.PathPrefix); // we need to caputre this var CurrentLocals = this.CurrentLocals; a.GetArguments().AsParametersTo( new sendname { BeforeInvoke = e => { // somebody sent sendname } }.Invoke, new findname { BeforeInvoke = e => { // somebody sent findname } }.Invoke, new asknames { BeforeInvoke = e => { a.ContentType = "text/plain"; a.Content = CurrentLocals.ToJSON(); } }.Invoke, new sendmessage { PrimaryThreadQueue = PrimaryThreadQueue, Display = e => { // we should already be in the correct thread AddTextMessageAndUpdate(e); } }.Invoke ); a.SetLogText(History.ToString()); //PrimaryThreadQueue.Enqueue(UpdateText); }
private void ForkClient(Stream s) { // http://en.wikipedia.org/wiki/List_of_HTTP_headers // somebody connected to us // this is a new thread var a = new IncomingDataArguments { Server = this }; var hr = new HeaderReader(); var LogText = ""; hr.Method += (method, path) => { Console.WriteLine(path); a.PathAndQuery = path; a.SetLogText = k => LogText = k; RaiseIncomingData(this, a); }; hr.Header += (key, value) => { //Console.WriteLine(key + ": " + value); }; hr.Read(s); var w = new BinaryWriter(s); var ww = new StringBuilder(); // default response ww.AppendLine("HTTP/1.0 200 OK"); ww.AppendLine("Content-Type: " + a); ww.AppendLine(); if (a.Content == null) { foreach (var k in this.Locals) { ww.AppendLine("<div>at this location you can talk to <b>" + k.Name + "</b></div>"); } // show remote users? ww.AppendLine("<hr />"); ww.AppendLine("<pre>"); // escape html entities? ww.AppendLine(LogText); ww.AppendLine("</pre>"); } else { ww.Append(a.Content); } w.Write(Encoding.ASCII.GetBytes(ww.ToString())); s.Close(); }
public void RaiseIncomingData(WebServerProvider sender, IncomingDataArguments args) { if (IncomingData != null) IncomingData(sender, args); }