GetQueuedMessages() public method

public GetQueuedMessages ( String session_id, String content_type ) : String
session_id String
content_type String
return String
Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            String       session_id   = context.Session.SessionID;
            HttpResponse response     = context.Response;
            HttpRequest  request      = context.Request;
            String       content_type = request.ContentType;

            response.ContentType  = request.ContentType;
            response.Expires      = 0;
            response.CacheControl = "Private"; //no-cache, no-store, private, must-revalidate

            //This is needed to prevent the SessionID from changing on every request (if nothing is stored
            //in the session object
            context.Session["make_persistant"] = 1;

            String response_text = "";

            if ((content_type == "" || content_type.Contains(TEXT_HTML)) && request.QueryString.GetValues("initial") != null)
            {
                return;
            }

            content_type = content_type.Contains(XML_JSON) ? XML_JSON : APPLICATION_JSON;

            logger.Debug("Received HTTP Reqest of type: " + request.HttpMethod + " with content_type of " + content_type);
            switch (request.HttpMethod)
            {
            case "GET":     // Send waiting message(s) to client [from queue]
                response_text = dispatcher.GetQueuedMessages(session_id, content_type);
                break;

            case "POST":     // Dispatch incoming message(s) and send waiting message(s) to client [[from queue]
                RequestDetails requestdetails   = new RequestDetails(request.InputStream, content_type);
                List <Message> incomingMessages = serviceManager.ParseIncomingMessages(context, this, requestdetails, content_type);

                //Dispatch each incoming message from the list here once dispatcher, listeners are both done
                dispatcher.Dispatch(incomingMessages, serviceManager, request, response, context.Session, this);
                response_text = dispatcher.GetQueuedMessages(session_id, content_type);
                break;
            }

            response.Write(response_text);
        }