*/\r
private boolean passThru=true;\r
/**\r
+ * internal flag - set to true to sleep until passThru is true before passing on a message\r
+ */\r
+ private boolean qUEUE=false;\r
+ /**\r
* the client apps message handler\r
*/\r
IMessageHandler pickHandler=null;\r
}\r
\r
public synchronized void sendMessage(Message message) {\r
- manager.sendMessage(message);\r
+ // throw away messages whilst we block\r
+ if (passThru && manager!=null)\r
+ manager.sendMessage(message);\r
}\r
/**\r
* pass message onto the Apps handler, or wait until\r
* @param message\r
*/\r
protected synchronized void handleMessage(Message message) {\r
- while (!passThru) {\r
+ if (qUEUE) {\r
+ while (!passThru && manager!=null) {\r
+ log.debug("Not passing through.");\r
try {\r
Thread.sleep(5);\r
} catch (InterruptedException e) {};\r
+ } \r
}\r
- if (passThru)\r
+ if (passThru && manager!=null)\r
pickHandler.handleMessage(message);\r
}\r
\r
public void setPassThru(boolean passThru) {\r
this.passThru = passThru;\r
}\r
- \r
+ /**\r
+ * shutdown the pickmanager and remove all references to it\r
+ */\r
public void shutdown() {\r
- manager.shutdown();\r
+ passThru=false;\r
+ manager.registerMessageHandler(null);\r
+ SocketManager dying = manager;\r
+ manager=null;\r
+ dying.shutdown();\r
}\r
}\r