@Test public void testCreateOpenResp() throws Exception { ByteBuf message = MessageFactory.createOpenResp(Version.Version4, ConnectionMode.Listener, nodeId, 120, 150); byte[] result = new byte[] {0, 0, 0, 32, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 2, 80, 6, 6, 3, 0, 2, 0, 1, 0, 80, 7, 4, 0, 120, 0, -106}; assertArrayEquals(result, toBytes(message)); message = MessageFactory.createOpenResp(Version.Version4, ConnectionMode.Speaker, nodeId, 120, 150); result = new byte[] {0, 0, 0, 30, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 1, 80, 5, 4, -64, -88, 0, 1, 80, 7, 4, 0, 120, 0, -106}; assertArrayEquals(result, toBytes(message)); }
private static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, Attribute attribute) throws CapabilityLengthException, AttributeVariantException { AttributeList attributes = createOpenAttribute(version, nodeMode, nodeID); if (attribute != null) { attributes.add(attribute); } byte[] payload = ArraysUtil.combine(new byte[] {0x00, 0x00, 0x00, (byte) version.getIntValue(), 0x00, 0x00, 0x00, (byte) nodeMode.getIntValue()}, attributes.toBytes()); return getMessage(MessageType.OpenResp, payload); }
MessageFactory { private static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, Attribute attribute) throws CapabilityLengthException, AttributeVariantException { AttributeList attributes = createOpenAttribute(version, nodeMode, nodeID); if (attribute != null) { attributes.add(attribute); } byte[] payload = ArraysUtil.combine(new byte[] {0x00, 0x00, 0x00, (byte) version.getIntValue(), 0x00, 0x00, 0x00, (byte) nodeMode.getIntValue()}, attributes.toBytes()); return getMessage(MessageType.OpenResp, payload); } }
MessageFactory { private static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, Attribute attribute) throws CapabilityLengthException, AttributeVariantException { AttributeList attributes = createOpenAttribute(version, nodeMode, nodeID); if (attribute != null) { attributes.add(attribute); } byte[] payload = ArraysUtil.combine(new byte[] {0x00, 0x00, 0x00, (byte) version.getIntValue(), 0x00, 0x00, 0x00, (byte) nodeMode.getIntValue()}, attributes.toBytes()); return getMessage(MessageType.OpenResp, payload); }  }
MessageFactory { private static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, Attribute attribute) throws CapabilityLengthException, AttributeVariantException { AttributeList attributes = createOpenAttribute(version, nodeMode, nodeID); if (attribute != null) { attributes.add(attribute); } byte[] payload = ArraysUtil.combine(new byte[] {0x00, 0x00, 0x00, (byte) version.getIntValue(), 0x00, 0x00, 0x00, (byte) nodeMode.getIntValue()}, attributes.toBytes()); return getMessage(MessageType.OpenResp, payload); }  static ByteBuf createError(ErrorCode errorCode, ErrorSubCode errorSubCode, byte[] data); static ByteBuf createKeepalive(); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMinAcceptable); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID,
            int holdTimeMinAcceptable); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createPurgeAll(); static ByteBuf createUpdate(List<R> deleteBindings,
            List<T> addBindings, NodeId nodeId, List<CapabilityType> capabilities, SxpBindingFilter bindingFilter); static Notification decodeErrorMessage(byte[] payload); static Notification decodeKeepalive(byte[] payload); static Notification decodeOpen(byte[] payload); static Notification decodeOpenResp(byte[] payload); static Version extractVersion(final byte[] payload); static Notification decodePurgeAll(byte[] payload); static Notification decodeUpdate(byte[] payload); static Notification parse(Version version, ByteBuf request); static String toString(byte[] message); static String toString(ByteBuf message); static String toString(Notification message); static List<CapabilityType> decodeCapabilities(OpenMessage message); }
MessageFactory { private static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, Attribute attribute) throws CapabilityLengthException, AttributeVariantException { AttributeList attributes = createOpenAttribute(version, nodeMode, nodeID); if (attribute != null) { attributes.add(attribute); } byte[] payload = ArraysUtil.combine(new byte[] {0x00, 0x00, 0x00, (byte) version.getIntValue(), 0x00, 0x00, 0x00, (byte) nodeMode.getIntValue()}, attributes.toBytes()); return getMessage(MessageType.OpenResp, payload); }  static ByteBuf createError(ErrorCode errorCode, ErrorSubCode errorSubCode, byte[] data); static ByteBuf createKeepalive(); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMinAcceptable); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID,
            int holdTimeMinAcceptable); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createPurgeAll(); static ByteBuf createUpdate(List<R> deleteBindings,
            List<T> addBindings, NodeId nodeId, List<CapabilityType> capabilities, SxpBindingFilter bindingFilter); static Notification decodeErrorMessage(byte[] payload); static Notification decodeKeepalive(byte[] payload); static Notification decodeOpen(byte[] payload); static Notification decodeOpenResp(byte[] payload); static Version extractVersion(final byte[] payload); static Notification decodePurgeAll(byte[] payload); static Notification decodeUpdate(byte[] payload); static Notification parse(Version version, ByteBuf request); static String toString(byte[] message); static String toString(ByteBuf message); static String toString(Notification message); static List<CapabilityType> decodeCapabilities(OpenMessage message);  }