2 import org.opensrf.net.xmpp.XMPPMessage;
3 import org.opensrf.util.*;
6 import java.util.Iterator;
11 public static void processXMPPMessage(XMPPMessage msg) {
13 if(msg == null) return;
15 /** fetch this session from the cache */
16 Session ses = Session.findCachedSession(msg.getThread());
19 /** inbound client request, create a new server session */
23 /** parse the JSON message body, which should result in a list of OpenSRF messages */
27 msgList = new JSONReader(msg.getBody()).readArray();
28 } catch(JSONException e) {
34 Iterator itr = msgList.iterator();
36 OSRFObject obj = null;
37 long start = new Date().getTime();
39 /** cycle through the messages and push them up the stack */
40 while(itr.hasNext()) {
42 /** Construct a Message object from the parsed generic OSRFObject */
43 obj = (OSRFObject) itr.next();
48 obj.getInt("threadTrace"),
49 obj.getString("type"),
55 /** LOG the duration */
58 private static void processOSRFMessage(Session ses, Message msg) {
59 if( ses instanceof ClientSession )
60 processResponse((ClientSession) ses, msg);
62 processRequest((ServerSession) ses, msg);
66 * Process a server response
68 private static void processResponse(ClientSession session, Message msg) {
69 if(msg.RESULT.equals(msg.getType())) {
70 session.pushResponse(msg);
76 * Process a client request
78 private static void processRequest(ServerSession session, Message msg) {