List of usage examples for io.netty.buffer ByteBuf readShort
public abstract short readShort();
From source file:org.traccar.protocol.RuptelaProtocolDecoder.java
License:Apache License
private long readValue(ByteBuf buf, int length, boolean signed) { switch (length) { case 1:/*from www .j av a 2 s . co m*/ return signed ? buf.readByte() : buf.readUnsignedByte(); case 2: return signed ? buf.readShort() : buf.readUnsignedShort(); case 4: return signed ? buf.readInt() : buf.readUnsignedInt(); default: return buf.readLong(); } }
From source file:org.traccar.protocol.T800xProtocolDecoder.java
License:Apache License
@Override protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { ByteBuf buf = (ByteBuf) msg; short header = buf.readShort(); int type = buf.readUnsignedByte(); buf.readUnsignedShort(); // length int index = buf.readUnsignedShort(); ByteBuf imei = buf.readSlice(8);// w w w . j av a 2 s. com DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, ByteBufUtil.hexDump(imei).substring(1)); if (deviceSession == null) { return null; } if (type == MSG_GPS || type == MSG_ALARM) { return decodePosition(channel, deviceSession, buf, header, type, index, imei); } else if (type == MSG_COMMAND) { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); getLastLocation(position, null); buf.readUnsignedByte(); // protocol number position.set(Position.KEY_RESULT, buf.toString(StandardCharsets.UTF_16LE)); sendResponse(channel, header, type, index, imei, 0); return position; } sendResponse(channel, header, type, index, imei, 0); return null; }
From source file:org.traccar.protocol.TeltonikaProtocolDecoder.java
License:Apache License
private void decodeLocation(Position position, ByteBuf buf, int codec) { int globalMask = 0x0f; if (codec == CODEC_GH3000) { long time = buf.readUnsignedInt() & 0x3fffffff; time += 1167609600; // 2007-01-01 00:00:00 globalMask = buf.readUnsignedByte(); if (BitUtil.check(globalMask, 0)) { position.setTime(new Date(time * 1000)); int locationMask = buf.readUnsignedByte(); if (BitUtil.check(locationMask, 0)) { position.setLatitude(buf.readFloat()); position.setLongitude(buf.readFloat()); }//from www .j a v a 2 s . c om if (BitUtil.check(locationMask, 1)) { position.setAltitude(buf.readUnsignedShort()); } if (BitUtil.check(locationMask, 2)) { position.setCourse(buf.readUnsignedByte() * 360.0 / 256); } if (BitUtil.check(locationMask, 3)) { position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); } if (BitUtil.check(locationMask, 4)) { position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); } if (BitUtil.check(locationMask, 5)) { CellTower cellTower = CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort()); if (BitUtil.check(locationMask, 6)) { cellTower.setSignalStrength((int) buf.readUnsignedByte()); } if (BitUtil.check(locationMask, 7)) { cellTower.setOperator(buf.readUnsignedInt()); } position.setNetwork(new Network(cellTower)); } else { if (BitUtil.check(locationMask, 6)) { position.set(Position.KEY_RSSI, buf.readUnsignedByte()); } if (BitUtil.check(locationMask, 7)) { position.set(Position.KEY_OPERATOR, buf.readUnsignedInt()); } } } else { getLastLocation(position, new Date(time * 1000)); } } else { position.setTime(new Date(buf.readLong())); position.set("priority", buf.readUnsignedByte()); position.setLongitude(buf.readInt() / 10000000.0); position.setLatitude(buf.readInt() / 10000000.0); position.setAltitude(buf.readShort()); position.setCourse(buf.readUnsignedShort()); int satellites = buf.readUnsignedByte(); position.set(Position.KEY_SATELLITES, satellites); position.setValid(satellites != 0); position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort())); position.set(Position.KEY_EVENT, readExtByte(buf, codec, CODEC_8_EXT, CODEC_16)); if (codec == CODEC_16) { buf.readUnsignedByte(); // generation type } readExtByte(buf, codec, CODEC_8_EXT); // total IO data records } // Read 1 byte data if (BitUtil.check(globalMask, 1)) { int cnt = readExtByte(buf, codec, CODEC_8_EXT); for (int j = 0; j < cnt; j++) { decodeParameter(position, readExtByte(buf, codec, CODEC_8_EXT, CODEC_16), buf, 1, codec); } } // Read 2 byte data if (BitUtil.check(globalMask, 2)) { int cnt = readExtByte(buf, codec, CODEC_8_EXT); for (int j = 0; j < cnt; j++) { decodeParameter(position, readExtByte(buf, codec, CODEC_8_EXT, CODEC_16), buf, 2, codec); } } // Read 4 byte data if (BitUtil.check(globalMask, 3)) { int cnt = readExtByte(buf, codec, CODEC_8_EXT); for (int j = 0; j < cnt; j++) { decodeParameter(position, readExtByte(buf, codec, CODEC_8_EXT, CODEC_16), buf, 4, codec); } } // Read 8 byte data if (codec == CODEC_8 || codec == CODEC_8_EXT || codec == CODEC_16) { int cnt = readExtByte(buf, codec, CODEC_8_EXT); for (int j = 0; j < cnt; j++) { decodeOtherParameter(position, readExtByte(buf, codec, CODEC_8_EXT, CODEC_16), buf, 8); } } // Read 16 byte data if (extended) { int cnt = readExtByte(buf, codec, CODEC_8_EXT); for (int j = 0; j < cnt; j++) { int id = readExtByte(buf, codec, CODEC_8_EXT, CODEC_16); position.set(Position.PREFIX_IO + id, ByteBufUtil.hexDump(buf.readSlice(16))); } } // Read X byte data if (codec == CODEC_8_EXT) { int cnt = buf.readUnsignedShort(); for (int j = 0; j < cnt; j++) { int id = buf.readUnsignedShort(); int length = buf.readUnsignedShort(); if (id == 256) { position.set(Position.KEY_VIN, buf.readSlice(length).toString(StandardCharsets.US_ASCII)); } else { position.set(Position.PREFIX_IO + id, ByteBufUtil.hexDump(buf.readSlice(length))); } } } decodeNetwork(position); }
From source file:org.traccar.protocol.Xt2400ProtocolDecoder.java
License:Apache License
@Override protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { ByteBuf buf = (ByteBuf) msg; byte[] format = null; if (formats.size() > 1) { format = formats.get(buf.getUnsignedByte(buf.readerIndex())); } else if (!formats.isEmpty()) { format = formats.values().iterator().next(); }//from w ww .j av a2s . c o m if (format == null) { return null; } Position position = new Position(getProtocolName()); for (byte tag : format) { switch (tag) { case 0x03: DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, String.valueOf(buf.readUnsignedInt())); if (deviceSession == null) { return null; } position.setDeviceId(deviceSession.getDeviceId()); break; case 0x04: position.set(Position.KEY_EVENT, buf.readUnsignedByte()); break; case 0x05: position.set(Position.KEY_INDEX, buf.readUnsignedShort()); break; case 0x06: position.setTime(new Date(buf.readUnsignedInt() * 1000)); break; case 0x07: position.setLatitude(buf.readInt() * 0.000001); break; case 0x08: position.setLongitude(buf.readInt() * 0.000001); break; case 0x09: position.setAltitude(buf.readShort() * 0.1); break; case 0x0a: position.setCourse(buf.readShort() * 0.1); break; case 0x0b: position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); break; case 0x10: position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt()); break; case 0x12: position.set(Position.KEY_HDOP, buf.readUnsignedByte() * 0.1); break; case 0x13: position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); break; case 0x14: position.set(Position.KEY_RSSI, buf.readShort()); break; case 0x16: position.set(Position.KEY_BATTERY, buf.readUnsignedByte() * 0.1); break; case 0x17: position.set(Position.KEY_POWER, buf.readUnsignedByte() * 0.1); break; case 0x57: position.set(Position.KEY_OBD_SPEED, UnitsConverter.knotsFromKph(buf.readUnsignedShort())); break; case 0x65: position.set(Position.KEY_VIN, buf.readSlice(17).toString(StandardCharsets.US_ASCII)); break; case 0x73: position.set(Position.KEY_VERSION_FW, buf.readSlice(16).toString(StandardCharsets.US_ASCII).trim()); break; default: buf.skipBytes(getTagLength(tag)); break; } } if (position.getLatitude() != 0 && position.getLongitude() != 0) { position.setValid(true); } else { getLastLocation(position, position.getDeviceTime()); } return position; }
From source file:org.virtue.network.protocol.creation.CreationDecoder.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception { if (!buf.isReadable()) { return;//www . j a v a 2 s . c o m } int size = buf.readShort() & 0xFFFF; if (buf.readableBytes() < size) throw new IllegalStateException( "Not enough readable bytes from buffer! " + size + ", " + buf.readableBytes()); int major = buf.readShort(); int minor = buf.readShort(); if (major != Constants.FRAME_MAJOR && minor != Constants.FRAME_MINOR) { throw new ProtocolException("Invalid client version/sub-version! found: " + major + " " + minor + ", expected: " + Constants.FRAME_MAJOR + " " + Constants.FRAME_MINOR); } int secureBufferSize = buf.readShort() & 0xFFFF; if (buf.readableBytes() < secureBufferSize) { throw new IllegalStateException("Not enough readable bytes from buffer."); } byte[] secureBytes = new byte[secureBufferSize]; buf.readBytes(secureBytes); ByteBuf secureBuffer = Unpooled.wrappedBuffer(new BigInteger(secureBytes) .modPow(Constants.getLoginKey(), Constants.getLoginModulus()).toByteArray()); int block = secureBuffer.readByte() & 0xFF; if (block != 10) throw new ProtocolException("Invalid block opcode: " + block); int[] xteaKey = new int[4]; for (int i = 0; i < xteaKey.length; i++) xteaKey[i] = secureBuffer.readInt(); for (int i = 0; i < 10; i++) ; secureBuffer.readInt(); secureBuffer.readShort(); byte[] xteaBlock = new byte[buf.readableBytes()]; buf.readBytes(xteaBlock); XTEACipher xtea = new XTEACipher(xteaKey); xtea.decrypt(xteaBlock, 0, xteaBlock.length); ByteBuf xteaBuffer = Unpooled.wrappedBuffer(xteaBlock); String token = BufferUtility.readString(xteaBuffer); if (!token.equals(Constants.getJs5Token())) { throw new ProtocolException("Invalid creation token: " + token); } xteaBuffer.readShort(); xteaBuffer.readInt(); xteaBuffer.readInt(); BufferUtility.readString(xteaBuffer); xteaBuffer.readByte(); xteaBuffer.readByte(); int[] randomData = new int[24]; for (int index = 0; index < randomData.length; index++) { randomData[index] = xteaBuffer.readUnsignedByte(); } boolean stringIsNotNull = xteaBuffer.readByte() == 1; if (stringIsNotNull) BufferUtility.readString(xteaBuffer); xteaBuffer.readByte(); xteaBuffer.readByte(); xteaBuffer.readByte(); xteaBuffer.readByte(); xteaBuffer.readByte(); xteaBuffer.readByte(); xteaBuffer.readByte(); xteaBuffer.readByte(); xteaBuffer.readByte(); xteaBuffer.readShort(); xteaBuffer.readByte(); BufferUtility.getTriByte(xteaBuffer); xteaBuffer.readShort(); BufferUtility.readJagString(xteaBuffer); BufferUtility.readJagString(xteaBuffer); BufferUtility.readJagString(xteaBuffer); BufferUtility.readJagString(xteaBuffer); xteaBuffer.readByte(); xteaBuffer.readShort(); BufferUtility.readJagString(xteaBuffer); BufferUtility.readJagString(xteaBuffer); xteaBuffer.readByte(); xteaBuffer.readByte(); int[] tri = new int[3]; for (int index = 0; index < tri.length; index++) { tri[index] = xteaBuffer.readInt(); } xteaBuffer.readInt(); BufferUtility.readJagString(xteaBuffer); int[] serverKeys = new int[xteaKey.length]; for (int i = 0; i < serverKeys.length; i++) { serverKeys[i] = xteaKey[i] + 50; } Player player = new Player(ctx.channel(), new ISAACCipher(serverKeys), new ISAACCipher(xteaKey)); player.setGameState(GameState.CREATION); player.setPrivilgeLevel(PrivilegeLevel.PLAYER); player.initialize(false, Virtue.getInstance().getConfigProvider()); ctx.channel().writeAndFlush(Unpooled.buffer(1).writeByte(2)); ctx.channel().pipeline().remove(this); ctx.channel().pipeline().addFirst("decoder", new ProtocolDecoder(player.getDecodingCipher())); ctx.channel().attr(NetworkHandler.attachment).set(new GameSession(ctx.channel(), player)); player.getModel().setTemp(); player.getModel().sendBlock(true, Virtue.getInstance().getConfigProvider().getWearposDefaults()); LoginDispatcher.onAccountCreation(player); //out.add(new CreationRequestMessage(ctx.channel(), new ISAACCipher(serverKeys), new ISAACCipher(serverKeys))); }
From source file:org.virtue.network.protocol.event.GameEventDecoder.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception { if (buf.isReadable()) { int opcode = buf.readByte() - cipher.nextInt() & 0xFF; if (opcode < 0) { buf.discardReadBytes();//from ww w. j a v a2s . com return; } int length = Constants.PACKET_SIZES[opcode]; if (length < 0) { switch (length) { case -1: if (buf.isReadable()) { length = buf.readByte() & 0xff; } break; case -2: if (buf.readableBytes() >= 2) { length = buf.readShort() & 0xffff; } break; default: length = buf.readableBytes(); break; } } if (buf.readableBytes() >= length) { if (length < 0) { return; } byte[] payload = new byte[length]; buf.readBytes(payload, 0, length); out.add(new GameEventMessage(opcode, new InboundBuffer(payload))); } } }
From source file:org.virtue.network.protocol.login.LoginDecoder.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception { if (!buf.isReadable()) { return;/*from ww w . j a v a 2s .c om*/ //throw new IllegalStateException("Not enough readable bytes from buffer!"); } int loginType = buf.readByte() & 0xFF; if (loginType == 26) { out.add(new LoginRequestMessage(LoginTypeMessage.LOGIN_CONTINUE)); return; } if (loginType != 16 && loginType != 19 && loginType != 18 && loginType != 60) { throw new ProtocolException("Invalid login type: " + loginType); } type = loginType == 19 ? LoginTypeMessage.LOGIN_LOBBY : LoginTypeMessage.LOGIN_WORLD; size = buf.readShort() & 0xFFFF; if (buf.readableBytes() < size) { throw new IllegalStateException("Not enough readable bytes from buffer!"); } byte[] block = new byte[size]; buf.readBytes(block); buf = Unpooled.wrappedBuffer(block); int version = buf.readInt(); int subVersion = buf.readInt(); System.out.printf("LoginDecoder:: Type(%s) size(%d) version %d %d\n", type + "", size, version, subVersion); if (version != Constants.FRAME_MAJOR && subVersion != Constants.FRAME_MINOR) { throw new ProtocolException("Invalid client version/sub-version! found: " + version + " " + subVersion + ", expected: " + Constants.FRAME_MAJOR + " " + Constants.FRAME_MINOR); } if (type.equals(LoginTypeMessage.LOGIN_WORLD)) { buf.readByte(); } if (type.equals(LoginTypeMessage.LOGIN_LOBBY)) { decodeLobbyPayload(ctx, buf, out); } else if (type.equals(LoginTypeMessage.LOGIN_WORLD)) { decodeGamePayload(ctx, buf, out); } }
From source file:org.virtue.network.protocol.login.LoginDecoder.java
License:Open Source License
private void decodeLobbyPayload(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws ProtocolException { if (buf.readableBytes() < 2) throw new IllegalStateException("Not enough readable bytes from buffer."); int secureBufferSize = buf.readShort() & 0xFFFF; if (buf.readableBytes() < secureBufferSize) throw new IllegalStateException("Not enough readable bytes from buffer."); byte[] secureBytes = new byte[secureBufferSize]; buf.readBytes(secureBytes);//from www. j a v a 2 s . c om ByteBuf secureBuffer = Unpooled.wrappedBuffer(new BigInteger(secureBytes) .modPow(Constants.getLoginKey(), Constants.getLoginModulus()).toByteArray()); int blockOpcode = secureBuffer.readByte() & 0xFF; if (blockOpcode != 10) { throw new ProtocolException("Invalid block opcode: " + blockOpcode); } int[] xteaKey = new int[4]; for (int i = 0; i < xteaKey.length; i++) { xteaKey[i] = secureBuffer.readInt(); } secureBuffer.readByte(); secureBuffer.readInt(); //if (loginHash != 0) //throw new ProtocolException("Invalid login hash: " + loginHash); String password = BufferUtility.readString(secureBuffer); long[] loginSeeds = new long[2]; for (int i = 0; i < loginSeeds.length; i++) { loginSeeds[i] = secureBuffer.readLong(); } byte[] xteaBlock = new byte[buf.readableBytes()]; buf.readBytes(xteaBlock); XTEACipher xtea = new XTEACipher(xteaKey); xtea.decrypt(xteaBlock, 0, xteaBlock.length); ByteBuf xteaBuffer = Unpooled.wrappedBuffer(xteaBlock); boolean decodeAsString = xteaBuffer.readByte() == 1; String username = decodeAsString ? BufferUtility.readString(xteaBuffer) : Base37Utility.decodeBase37(xteaBuffer.readLong()); xteaBuffer.readUnsignedByte();//Game ID xteaBuffer.readUnsignedByte();//Language ID xteaBuffer.readUnsignedByte();//Frame type (Fixed, Resizable, or Full Screen) xteaBuffer.readUnsignedShort();//Canvas Width xteaBuffer.readUnsignedShort();//Canvas Height xteaBuffer.readUnsignedByte(); int[] randomData = new int[24]; for (int index = 0; index < randomData.length; index++) { randomData[index] = xteaBuffer.readUnsignedByte(); } String token = BufferUtility.readString(xteaBuffer);//Site Settings if (!token.equals(Constants.getLoginToken())) throw new IllegalStateException("Invalid server token. " + token); int length = xteaBuffer.readUnsignedByte(); byte[] machineData = new byte[length]; for (int data = 0; data < machineData.length; data++) { machineData[data] = (byte) xteaBuffer.readUnsignedByte(); } xteaBuffer.readInt(); BufferUtility.readString(xteaBuffer); xteaBuffer.readInt(); xteaBuffer.readInt(); BufferUtility.readString(xteaBuffer); xteaBuffer.readUnsignedByte(); int[] cacheCRC = new int[36]; for (int index = 0; index < cacheCRC.length; index++) { cacheCRC[index] = xteaBuffer.readInt(); } int[] serverKeys = new int[xteaKey.length]; for (int i = 0; i < serverKeys.length; i++) { serverKeys[i] = xteaKey[i] + 50; } System.out.println("Username = " + username); //System.out.println("Password = " + password); out.add(new LoginRequestMessage(ctx.channel(), UsernameUtility.formatForProtocol(username), password, username.contains("@"), new ISAACCipher(serverKeys), new ISAACCipher(xteaKey), type)); }
From source file:org.virtue.network.protocol.login.LoginDecoder.java
License:Open Source License
private void decodeGamePayload(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws ProtocolException { if (buf.readableBytes() < 2) { throw new IllegalStateException("Not enough readable bytes from buffer."); }/* w w w. ja v a 2s.c o m*/ int secureBufferSize = buf.readShort() & 0xFFFF; if (buf.readableBytes() < secureBufferSize) { throw new IllegalStateException("Not enough readable bytes from buffer."); } byte[] secureBytes = new byte[secureBufferSize]; buf.readBytes(secureBytes); ByteBuf secureBuffer = Unpooled.wrappedBuffer(new BigInteger(secureBytes) .modPow(Constants.getLoginKey(), Constants.getLoginModulus()).toByteArray()); int blockOpcode = secureBuffer.readByte() & 0xFF; if (blockOpcode != 10) { throw new ProtocolException("Invalid block opcode: " + blockOpcode); } int[] xteaKey = new int[4]; for (int i = 0; i < xteaKey.length; i++) xteaKey[i] = secureBuffer.readInt(); secureBuffer.readLong(); //if (loginHash != 0) //throw new ProtocolException("Invalid login hash: " + loginHash); secureBuffer.readByte(); secureBuffer.readerIndex(secureBuffer.readerIndex() - 4); String password = BufferUtility.readString(secureBuffer); long[] loginSeeds = new long[2]; for (int i = 0; i < loginSeeds.length; i++) loginSeeds[i] = secureBuffer.readLong(); byte[] xteaBlock = new byte[buf.readableBytes()]; buf.readBytes(xteaBlock); XTEACipher xtea = new XTEACipher(xteaKey); xtea.decrypt(xteaBlock, 0, xteaBlock.length); ByteBuf xteaBuffer = Unpooled.wrappedBuffer(xteaBlock); boolean decodeAsString = xteaBuffer.readByte() == 1; String username = decodeAsString ? BufferUtility.readString(xteaBuffer) : Base37Utility.decodeBase37(xteaBuffer.readLong()); xteaBuffer.readUnsignedByte(); xteaBuffer.readUnsignedShort();//Canvas Width xteaBuffer.readUnsignedShort();//Canvas Height xteaBuffer.readUnsignedByte(); int[] randomData = new int[24]; for (int index = 0; index < randomData.length; index++) { randomData[index] = xteaBuffer.readUnsignedByte(); } String token = BufferUtility.readString(xteaBuffer);//Site Settings if (!token.equals(Constants.getLoginToken())) { throw new IllegalStateException("Invalid server token."); } xteaBuffer.readInt(); int length = xteaBuffer.readUnsignedByte(); byte[] machineData = new byte[length]; for (int data = 0; data < machineData.length; data++) { machineData[data] = (byte) xteaBuffer.readUnsignedByte(); } xteaBuffer.readInt(); xteaBuffer.readInt();//User flow #2 xteaBuffer.readInt();//User flow #1 BufferUtility.readString(xteaBuffer); boolean extra = xteaBuffer.readUnsignedByte() == 1; if (extra) { BufferUtility.readString(xteaBuffer);//Create Additional Info } xteaBuffer.readUnsignedByte();//Javascript enabled xteaBuffer.readUnsignedByte();//Has Chrome browser xteaBuffer.readUnsignedByte(); xteaBuffer.readUnsignedByte(); xteaBuffer.readInt(); @SuppressWarnings("unused") String videoCard = BufferUtility.readString(xteaBuffer); xteaBuffer.readUnsignedByte(); xteaBuffer.readUnsignedShort();//Lobby node ID xteaBuffer.readUnsignedShort();//Media stream node ID int[] cacheCRC = new int[36]; for (int index = 0; index < cacheCRC.length; index++) { cacheCRC[index] = xteaBuffer.readInt(); } int[] serverKeys = new int[xteaKey.length]; for (int i = 0; i < serverKeys.length; i++) { serverKeys[i] = xteaKey[i] + 50; } out.add(new LoginRequestMessage(ctx.channel(), UsernameUtility.formatForProtocol(username), password, username.contains("@"), new ISAACCipher(serverKeys), new ISAACCipher(xteaKey), type)); }
From source file:org.virtue.network.protocol.ondemand.OnDemandDecoder.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception { if (buf.readableBytes() < 6) { return;//from www .j a v a2 s .c o m } int opcode = buf.readUnsignedByte(); if (opcode == 0 || opcode == 1) {// file priority request || normal request out.add(new OnDemandRequestMessage(opcode == 1, buf.readUnsignedByte(), buf.readInt())); } else if (opcode == 2 || opcode == 3) {// client logged in || logged out out.add(new OnDemandStateMessage(opcode == 2, (buf.readUnsignedByte() | buf.readInt()))); } else if (opcode == 4) {// encryption change out.add(new OnDemandEncryptionMessage(buf.readUnsignedByte(), buf.readInt())); } else if (opcode == 6) {// init connection out.add(new OnDemandInitMessage(buf.readUnsignedMedium(), buf.readShort())); } else if (opcode == 7) {// drop requests queue out.add(new OnDemandDropMessage(buf.readUnsignedByte() | buf.readInt())); } }