Exemple #1
0
 public static void PrintData(byte[] data, int len) {
   Log.info("readed count: " + Integer.toString(len));
   //		String s = "";
   //    	for(int i = 0; i < len; i++) {
   //    	    s += String.format("%02x ", data[i]);
   //    	}
   //    	Log.info("data: "+s);
 }
Exemple #2
0
    private void ProcessData(int readed) {
      byte[] buf;
      if (left_buf != null) {
        buf = new byte[left_buf.length + readed];
        System.arraycopy(left_buf, 0, buf, 0, left_buf.length);
        System.arraycopy(read_buffer, 0, buf, left_buf.length, readed);
        left_buf = null;
      } else {
        buf = new byte[readed];
        System.arraycopy(read_buffer, 0, buf, 0, readed);
      }
      // Log.info("process data readed="+readed);
      while (true) {

        // if (buf != null)
        // Log.info("buf len="+buf.length);
        // else
        // Log.info("buf null");

        if (is_header) {
          // Log.info("is header");

          if ((buf != null && buf.length < HEADER_SIZE) || buf == null) {
            left_buf = buf;
            break;
          }
          int data_len = Utils.uint16d(buf, 0) - HEADER_SIZE;
          int type = Utils.unsigned_byte(buf[2]);
          if (Config.debug_packets) Log.debug("new pkt: [" + type + "] len=" + data_len);
          cur_packet = new Packet(type, data_len);
          buf = cur_packet.add_data(buf, HEADER_SIZE, buf.length - HEADER_SIZE);
          if (cur_packet.is_ready()) {
            synchronized (Connection.this) {
              if (Config.debug_packets) Log.info("recv packet " + cur_packet.toString());
              cur_packet.offset = 0;
              synchronized (packets) {
                packets.addFirst(cur_packet);
              }
            }
            cur_packet = null;
          } else {
            is_header = false;
          }
        } else {
          // Log.info("not is header");
          if (buf == null) {
            left_buf = buf;
            break;
          }
          buf = cur_packet.add_data(buf, 0, buf.length);
          if (cur_packet.is_ready()) {
            synchronized (packets) {
              // Log.info("recv packet "+cur_packet.toString());
              cur_packet.offset = 0;
              packets.addFirst(cur_packet);
            }
            cur_packet = null;
            is_header = true;
          }
        }
      }
    }
 public LoadException(String msg) {
   super(msg);
   Log.info(msg);
 }
 public LoadException(String msg, Resource res) {
   super(msg);
   Log.info(msg);
   this.res = res;
 }
 public LoadException(String msg, Throwable cause, Resource res) {
   super(msg, cause);
   Log.info(msg);
   this.res = res;
 }
 public LoadException(Throwable cause, Resource res) {
   super("Loading error " + res.toString() + " >> " + res.source, cause);
   Log.info("Loading error " + res.toString() + " >> " + res.source);
   this.res = res;
 }