// we synchronize on ourselves, in case we are executed by several threads
  // from the thread pool.
  public synchronized void run() {
    // go over all complete messages and process them.
    while (_tokenizer.hasMessage()) {
      T msg = _tokenizer.nextMessage();

      try {
        this._protocol.processMessage(
            msg,
            new ProtocolCallback<T>() {

              public void sendMessage(T msg) throws IOException {
                if (msg != null)
                  try {
                    ByteBuffer bytes = _tokenizer.getBytesForMessage(msg);
                    ProtocolTask.this._handler.addOutData(bytes);
                  } catch (CharacterCodingException e) {
                    e.printStackTrace();
                  }
              }
            });
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Example #2
0
 // we synchronize on ourselves, in case we are executed by several threads
 // from the thread pool.
 public synchronized void run() {
   // go over all complete messages and process them.
   while (_tokenizer.hasMessage()) {
     T msg = _tokenizer.nextMessage();
     String temp = _tokenizer.getLastMessageSend(); // TODO delete
     try {
       this._tokenizer.setConnectionHandler(_handler);
     } catch (Exception e) {
     }
     T response = this._protocol.processMessage(msg);
     if (response != null) {
       try {
         ByteBuffer bytes = _tokenizer.getBytesForMessage(response);
         this._handler.addOutData(bytes);
       } catch (CharacterCodingException e) {
         e.printStackTrace();
       }
     } else {
     }
   }
 }
Example #3
0
 public void addBytes(ByteBuffer b) {
   _tokenizer.addBytes(b);
 }