Ejemplo n.º 1
0
        private static string Listen(HttpListener listener)
        {
            if (listener.IsListening)
            {
                Console.WriteLine("Listening...");
            }

            var context = listener.GetContext();

            var request = context.Request;

            if (request != null)
            {
                Console.WriteLine("Got a request");
            }
            else
            {
                throw new NetworkInformationException();
            }

            context.Response.StatusCode = 200;

            var reader = new Program.MessageReader(request.InputStream);

            reader.ReadMessage();


            context.Response.Close();
            return(reader.Body);
        }
Ejemplo n.º 2
0
        public void ListenerCallback(IAsyncResult result)
        {
            HttpListener        listener = (HttpListener)result.AsyncState;
            HttpListenerContext context  = listener.EndGetContext(result);
            HttpListenerRequest request  = context.Request;

            HttpListenerResponse response = context.Response;

            response.StatusCode = 200;


            var reader = new Program.MessageReader(request.InputStream);

            reader.ReadMessage();
            BuildandAddUsers(reader.Body, CurrentMessage);
            response.Close();

            var nextIteration = listener.BeginGetContext(ListenerCallback, listener);
        }