import java.io.InputStream;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.Date;
-
+import org.opensrf.util.Logger;
/**
* Slim XMPP Stream reader. This reader only understands enough XMPP
* Each reader should have exactly one dependent session thread.
*/
private synchronized void notifyCoreEvent() {
- notify();
+ notifyAll();
}
public synchronized long waitCoreEvent(long timeout) {
if(msgQueue.peek() != null || timeout == 0) return 0;
-
long start = new Date().getTime();
+
try{
- if(timeout < 0) wait();
- else wait(timeout);
+ if(timeout < 0)
+ wait();
+ else
+ wait(timeout);
} catch(InterruptedException ie) {}
return new Date().getTime() - start;
/**
* Parses XML data from the provided XMPP stream.
- * @param inStream The stream to parse.
*/
public void read() {
msg.setBody(msgBody.toString());
msg.setThread(msgThread.toString());
+ Logger.internal("xmpp message from="+msgFrom+" " + msg.getBody());
+
msgQueue.offer(msg);
resetBuffers();
notifyCoreEvent();
return;
}
+ if("opensrf".equals(name)) {
+ /** add a special case for the opensrf "router_from" attribute */
+ String rf = reader.getAttributeValue(null, "router_from");
+ if( rf != null )
+ msgFrom = rf;
+ return;
+ }
+
if("body".equals(name)) {
xmlState = XMLState.IN_BODY;
return;