コード例 #1
0
ファイル: IntMessage.java プロジェクト: BoscoK/vert.x
 @Override
 protected void readBody(int pos, Buffer readBuff) {
   boolean isNull = readBuff.getByte(pos) == (byte) 0;
   if (!isNull) {
     body = readBuff.getInt(++pos);
   }
 }
コード例 #2
0
 @Override
 public String decodeFromWire(int pos, Buffer buffer) {
   int length = buffer.getInt(pos);
   pos += 4;
   byte[] bytes = buffer.getBytes(pos, pos + length);
   return new String(bytes, CharsetUtil.UTF_8);
 }
コード例 #3
0
 @Override
 public User decodeFromWire(int pos, Buffer buffer) {
   int length = buffer.getInt(pos);
   pos += 4;
   byte[] encoded = buffer.getBytes(pos, pos + length);
   String str = new String(encoded, CharsetUtil.UTF_8);
   return JsonUtils.decode(str, User.class);
 }
コード例 #4
0
ファイル: ClusteredMessage.java プロジェクト: CowLeo/vert.x
 public void readFromWire(Buffer buffer, CodecManager codecManager) {
   int pos = 0;
   // Overall Length already read when passed in here
   byte protocolVersion = buffer.getByte(pos);
   if (protocolVersion > WIRE_PROTOCOL_VERSION) {
     throw new IllegalStateException(
         "Invalid wire protocol version "
             + protocolVersion
             + " should be <= "
             + WIRE_PROTOCOL_VERSION);
   }
   pos++;
   byte systemCodecCode = buffer.getByte(pos);
   pos++;
   if (systemCodecCode == -1) {
     // User codec
     int length = buffer.getInt(pos);
     pos += 4;
     byte[] bytes = buffer.getBytes(pos, pos + length);
     String codecName = new String(bytes, CharsetUtil.UTF_8);
     messageCodec = codecManager.getCodec(codecName);
     if (messageCodec == null) {
       throw new IllegalStateException("No message codec registered with name " + codecName);
     }
     pos += length;
   } else {
     messageCodec = codecManager.systemCodecs()[systemCodecCode];
   }
   byte bsend = buffer.getByte(pos);
   send = bsend == 0;
   pos++;
   int length = buffer.getInt(pos);
   pos += 4;
   byte[] bytes = buffer.getBytes(pos, pos + length);
   address = new String(bytes, CharsetUtil.UTF_8);
   pos += length;
   length = buffer.getInt(pos);
   pos += 4;
   if (length != 0) {
     bytes = buffer.getBytes(pos, pos + length);
     replyAddress = new String(bytes, CharsetUtil.UTF_8);
     pos += length;
   }
   int senderPort = buffer.getInt(pos);
   pos += 4;
   length = buffer.getInt(pos);
   pos += 4;
   bytes = buffer.getBytes(pos, pos + length);
   String senderHost = new String(bytes, CharsetUtil.UTF_8);
   pos += length;
   headersPos = pos;
   int headersLength = buffer.getInt(pos);
   pos += headersLength;
   bodyPos = pos;
   sender = new ServerID(senderPort, senderHost);
   wireBuffer = buffer;
   fromWire = true;
 }
コード例 #5
0
ファイル: ClusteredMessage.java プロジェクト: CowLeo/vert.x
 private void decodeHeaders() {
   int length = wireBuffer.getInt(headersPos);
   if (length != 4) {
     headersPos += 4;
     int numHeaders = wireBuffer.getInt(headersPos);
     headersPos += 4;
     headers = new CaseInsensitiveHeaders();
     for (int i = 0; i < numHeaders; i++) {
       int keyLength = wireBuffer.getInt(headersPos);
       headersPos += 4;
       byte[] bytes = wireBuffer.getBytes(headersPos, headersPos + keyLength);
       String key = new String(bytes, CharsetUtil.UTF_8);
       headersPos += keyLength;
       int valLength = wireBuffer.getInt(headersPos);
       headersPos += 4;
       bytes = wireBuffer.getBytes(headersPos, headersPos + valLength);
       String val = new String(bytes, CharsetUtil.UTF_8);
       headersPos += valLength;
       headers.add(key, val);
     }
   }
   headersPos = 0;
 }
コード例 #6
0
ファイル: JsonObject.java プロジェクト: PNRSoft/framework
 @Override
 public void readFromBuffer(Buffer buffer) {
   int length = buffer.getInt(0);
   String encoded = buffer.getString(4, 4 + length);
   fromJson(encoded);
 }