package buzzerproxy.bprot; import buzzerproxy.Crypto; import buzzerproxy.handler.QuestionInterface; /** * @author M. Friedeboldt */ public class Session implements Runnable { private String question; private QuestionInterface questionInterface; private boolean ready; private ByteProtResult protResult; /** * @param questionInterface */ public Session(QuestionInterface questionInterface) { this.questionInterface = questionInterface; this.ready = false; } /** * @param question */ public void setQuestion(String question) { this.question = question; new Thread( this ).start(); } /** * @return */ public boolean isReady() { return ready; } /** * @return */ public String getResult(int index, int max) { return protResult.getResult( index, max ); } /** * @return */ public int getAnswerCount() { return protResult.getCount(); } @Override public void run() { try { protResult = new ByteProtResult( questionInterface.request( question ) ); ready = true; } catch ( Exception e ) { e.printStackTrace(); } } public String getConfigXMLVersion() { return questionInterface.getConfigXMLVersion(); } public String getConfigurationXML() { return questionInterface.getConfigurationXML(); } }