Inheritance: IHttpHandler, IRequiresSessionState
Beispiel #1
0
 public Message(HttpSessionState session, ServiceBroker servicebroker)
 {
     this.session = session;
     this.servicebroker = servicebroker;
     sessionid = session.SessionID;
     json = new JsonObject();
 }
Beispiel #2
0
        /// <summary>
        /// Parses incoming messages and returns a list to be dispatched
        /// </summary>
        /// <param name="iter">The iterator with the message element list (xml)</param>
        /// <param name="context">The HttpContext of the request</param>
        /// <param name="broker">The ServiceBroker handling the request</param>
        /// <param name="details">The RequestDetails from the request</param>
        /// <returns></returns>
        public List <Message> ParseIncomingMessages(HttpContext context, ServiceBroker broker, RequestDetails details, String content_type)
        {
            List <Message> messages = new List <Message>();

            switch (content_type)
            {
            case ServiceBroker.APPLICATION_JSON:
                JsonArray messageArray = (JsonArray)details.JSON["messages"];

                foreach (JsonObject jsonMessage in messageArray)
                {
                    Message m = new Message(jsonMessage, context.Session, broker, details);
                    m.Direction = MessageDirection.INCOMING;
                    messages.Add(m);
                }
                break;

            case ServiceBroker.XML_JSON:
                XPathNodeIterator iter = details.XMLIterator;

                while (iter.MoveNext())
                {
                    Message m = new Message(iter.Current, context.Session, broker, details);
                    m.Direction = MessageDirection.INCOMING;
                    messages.Add(m);
                }
                break;
            }

            Logger.Instance.Debug("Parsed " + messages.Count + " incoming message(s)");
            return(messages);
        }
Beispiel #3
0
 public Message(HttpSessionState session, ServiceBroker servicebroker)
 {
     this.session       = session;
     this.servicebroker = servicebroker;
     sessionid          = session.SessionID;
     json = new JsonObject();
 }
Beispiel #4
0
 public Message(JsonObject message, HttpSessionState session, ServiceBroker servicebroker, RequestDetails details)
 {
     type = ((JsonString)message["type"]).Value;
     scope = ((JsonString)message["scope"]).Value;
     version = ((JsonString)message["version"]).Value;
     json = (JsonObject)message["data"];
     sessionid = session.SessionID;
     requestdetails = details;
     this.session = session;
     this.servicebroker = servicebroker;
 }
Beispiel #5
0
        //Sends messages to Services -- called from the ServiceBroker
        public void Dispatch(List<Message> messageList, ServiceManager manager, HttpRequest httprequest, HttpResponse httpresponse, HttpSessionState session, ServiceBroker broker)
        {
            Logger.Instance.Debug("Dispatching " + messageList.Count + " message(s) for Session ID: " + session.SessionID);

            foreach (Message request in messageList)
            {
                Message response = new Message(session, broker);
                response.Direction = MessageDirection.OUTGOING;
                manager.HandleRequest(request, response, session, httpresponse);
            }
        }
Beispiel #6
0
 public Message(JsonObject message, HttpSessionState session, ServiceBroker servicebroker, RequestDetails details)
 {
     type               = ((JsonString)message["type"]).Value;
     scope              = ((JsonString)message["scope"]).Value;
     version            = ((JsonString)message["version"]).Value;
     json               = (JsonObject)message["data"];
     sessionid          = session.SessionID;
     requestdetails     = details;
     this.session       = session;
     this.servicebroker = servicebroker;
 }
Beispiel #7
0
 public Message(XPathNavigator msgXML, HttpSessionState session, ServiceBroker servicebroker, RequestDetails details)
 {
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(msgXML.OuterXml);
     XmlElement msg = doc.DocumentElement;
     requestid = msg.GetAttribute("requestid");
     type = msg.GetAttribute("type").ToLower();
     scope = msg.GetAttribute("scope");
     version = msg.GetAttribute("version");
     sessionid = session.SessionID;
     json = parseMessagePayload(msg.InnerText);
     requestdetails = details;
     this.session = session;
     this.servicebroker = servicebroker;
 }
Beispiel #8
0
        public Message(XPathNavigator msgXML, HttpSessionState session, ServiceBroker servicebroker, RequestDetails details)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(msgXML.OuterXml);
            XmlElement msg = doc.DocumentElement;

            requestid          = msg.GetAttribute("requestid");
            type               = msg.GetAttribute("type").ToLower();
            scope              = msg.GetAttribute("scope");
            version            = msg.GetAttribute("version");
            sessionid          = session.SessionID;
            json               = parseMessagePayload(msg.InnerText);
            requestdetails     = details;
            this.session       = session;
            this.servicebroker = servicebroker;
        }
Beispiel #9
0
        //Sends messages to Services -- called from the ServiceBroker
        public void Dispatch(List <Message> messageList, ServiceManager manager, HttpRequest httprequest, HttpResponse httpresponse, HttpSessionState session, ServiceBroker broker)
        {
            Logger.Instance.Debug("Dispatching " + messageList.Count + " message(s) for Session ID: " + session.SessionID);

            foreach (Message request in messageList)
            {
                Message response = new Message(session, broker);
                response.Direction = MessageDirection.OUTGOING;
                manager.HandleRequest(request, response, session, httpresponse);
            }
        }
        /// <summary>
        /// Parses incoming messages and returns a list to be dispatched
        /// </summary>
        /// <param name="iter">The iterator with the message element list (xml)</param>
        /// <param name="context">The HttpContext of the request</param>
        /// <param name="broker">The ServiceBroker handling the request</param>
        /// <param name="details">The RequestDetails from the request</param>
        /// <returns></returns>
        public List<Message> ParseIncomingMessages(HttpContext context, ServiceBroker broker, RequestDetails details, String content_type)
        {
            List<Message> messages = new List<Message>();
            switch (content_type)
            {
                case ServiceBroker.APPLICATION_JSON:
                    JsonArray messageArray = (JsonArray)details.JSON["messages"];

                    foreach (JsonObject jsonMessage in messageArray)
                    {
                        Message m = new Message(jsonMessage, context.Session, broker, details);
                        m.Direction = MessageDirection.INCOMING;
                        messages.Add(m);
                    }
                    break;
                case ServiceBroker.XML_JSON:
                    XPathNodeIterator iter = details.XMLIterator;

                    while (iter.MoveNext())
                    {
                        Message m = new Message(iter.Current, context.Session, broker, details);
                        m.Direction = MessageDirection.INCOMING;
                        messages.Add(m);
                    }
                    break;
            }

            Logger.Instance.Debug("Parsed " + messages.Count + " incoming message(s)");
            return messages;
        }