@Test public void testDecodeOpen() throws Exception { OpenMessageLegacy message = (OpenMessageLegacy) LegacyMessageFactory.decodeOpen(new byte[] {0, 0, 0, 1, 0, 0, 0, 2}); assertEquals(ConnectionMode.Listener, message.getSxpMode()); assertEquals(Version.Version1, message.getVersion()); message = (OpenMessageLegacy) LegacyMessageFactory.decodeOpen(new byte[] {0, 0, 0, 1, 0, 0, 0, 1}); assertEquals(ConnectionMode.Speaker, message.getSxpMode()); assertEquals(Version.Version1, message.getVersion()); message = (OpenMessageLegacy) LegacyMessageFactory.decodeOpen(new byte[] {0, 0, 0, 2, 0, 0, 0, 2}); assertEquals(ConnectionMode.Listener, message.getSxpMode()); assertEquals(Version.Version2, message.getVersion()); message = (OpenMessageLegacy) LegacyMessageFactory.decodeOpen(new byte[] {0, 0, 0, 2, 0, 0, 0, 1}); assertEquals(ConnectionMode.Speaker, message.getSxpMode()); assertEquals(Version.Version2, message.getVersion()); message = (OpenMessageLegacy) LegacyMessageFactory.decodeOpen(new byte[] {0, 0, 0, 3, 0, 0, 0, 2}); assertEquals(ConnectionMode.Listener, message.getSxpMode()); assertEquals(Version.Version3, message.getVersion()); message = (OpenMessageLegacy) LegacyMessageFactory.decodeOpen(new byte[] {0, 0, 0, 3, 0, 0, 0, 1}); assertEquals(ConnectionMode.Speaker, message.getSxpMode()); assertEquals(Version.Version3, message.getVersion()); }
public static Notification decodeOpen(byte[] payload) { OpenMessageLegacyBuilder messageBuilder = new OpenMessageLegacyBuilder(); messageBuilder.setType(MessageType.Open); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); Version version = Version.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 0, 4))); ConnectionMode nodeMode = ConnectionMode.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 4, 4))); messageBuilder.setVersion(version); messageBuilder.setSxpMode(nodeMode); return messageBuilder.build(); }
LegacyMessageFactory extends MessageFactory { public static Notification decodeOpen(byte[] payload) { OpenMessageLegacyBuilder messageBuilder = new OpenMessageLegacyBuilder(); messageBuilder.setType(MessageType.Open); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); Version version = Version.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 0, 4))); ConnectionMode nodeMode = ConnectionMode.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 4, 4))); messageBuilder.setVersion(version); messageBuilder.setSxpMode(nodeMode); return messageBuilder.build(); } }
LegacyMessageFactory extends MessageFactory { public static Notification decodeOpen(byte[] payload) { OpenMessageLegacyBuilder messageBuilder = new OpenMessageLegacyBuilder(); messageBuilder.setType(MessageType.Open); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); Version version = Version.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 0, 4))); ConnectionMode nodeMode = ConnectionMode.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 4, 4))); messageBuilder.setVersion(version); messageBuilder.setSxpMode(nodeMode); return messageBuilder.build(); }  }
LegacyMessageFactory extends MessageFactory { public static Notification decodeOpen(byte[] payload) { OpenMessageLegacyBuilder messageBuilder = new OpenMessageLegacyBuilder(); messageBuilder.setType(MessageType.Open); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); Version version = Version.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 0, 4))); ConnectionMode nodeMode = ConnectionMode.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 4, 4))); messageBuilder.setVersion(version); messageBuilder.setSxpMode(nodeMode); return messageBuilder.build(); }  static ByteBuf createError(ErrorCodeNonExtended errorCode); static ByteBuf createError(ErrorCodeNonExtended errorCode, byte[] data); static ByteBuf createOpen(Version version, ConnectionMode nodeMode); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode); static ByteBuf createUpdate(List<T> deleteBindings, List<T> addBindings,
            Version version, SxpBindingFilter bindingFilter); static Notification decodeOpen(byte[] payload); static Notification decodeOpenResp(byte[] payload); static Notification decodeUpdate(byte[] payload); }
LegacyMessageFactory extends MessageFactory { public static Notification decodeOpen(byte[] payload) { OpenMessageLegacyBuilder messageBuilder = new OpenMessageLegacyBuilder(); messageBuilder.setType(MessageType.Open); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); Version version = Version.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 0, 4))); ConnectionMode nodeMode = ConnectionMode.forValue(ArraysUtil.bytes2int(ArraysUtil.readBytes(payload, 4, 4))); messageBuilder.setVersion(version); messageBuilder.setSxpMode(nodeMode); return messageBuilder.build(); }  static ByteBuf createError(ErrorCodeNonExtended errorCode); static ByteBuf createError(ErrorCodeNonExtended errorCode, byte[] data); static ByteBuf createOpen(Version version, ConnectionMode nodeMode); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode); static ByteBuf createUpdate(List<T> deleteBindings, List<T> addBindings,
            Version version, SxpBindingFilter bindingFilter); static Notification decodeOpen(byte[] payload); static Notification decodeOpenResp(byte[] payload); static Notification decodeUpdate(byte[] payload);  }