LrJposChannel.setHeader

Sets the channel header to use for the messages sent by the channel.

public static void setHeader(byte[] headerBytes)

public static void setHeader(String header)

Parameters

ParameterDescription
headerBytesProvides header as byte array.
headerProvides header as a string.

Return values

This function does not return any values.

General information

If the LrJposChannel.setOverrideHeader property is set to true, this header overrides the message header. If not, the channel header defined by this function is not used.

Example

Copy code
public void simpleISOtest() throws Throwable{
        
        GenericPackager packager = new GenericPackager(PACKAGERCONFIGFILE);
        LrJposChannel.initChannel(LrJposChannel.ChannelType.ASCIIChannel, "localhost", 8000, packager);
        LrJposChannel.setHeader("newHeader");
        
        LrJposChannel.connect();
        
        LrISOMsg m = new LrISOMsg();
        m.setMTI("0100");
        m.set(ISO87Fields.PAN_PRIMARY_ACCOUNT_NUMBER, "1234567890000000000")
        m.set(3, "523456")
        m.set(4, "123456789121")
        m.set(12, "20241605108110");  
        m.set(47, "32432")

        LrJposChannel.send(m);
        
        LrISOMsg r = LrJposChannel.receive();
        if (r!=null) {
            lr.output_message(r.getMTI());
        }
        
        byte[] currentHeader = LrJposChannel.getHeader();

        LrJposChannel.disconnect();
        LrJposChannel.closeChannel();
}