Share this page

# LrJposChannel.addFilter

Adds a filter to the filters list. Filters have the ability to modify a message.

You can add a filter for incoming messages, outgoing messages, or both.

`public static void addFilter(ISOFilter filter, int direction)`

`public static void addOutgoingFilter(ISOFilter filter)`

## Parameters

Parameter | Description
--- | ---
filter | The new filter to add to the list.
direction | Specifies the direction of the messages where the filter is to be applied: 0: The filter is applied to both incoming and outgoing messages. 1 - LrISOMsg.INCOMING: The filter is applied to incoming (received) messages. 2 - LrISOMsg.OUTGOING: The filter is applied to outgoing (sent) messages. Note: If direction is not specified, the filter is added for both incoming and outgoing messages.

## Return values

This function does not return any values.

## Example

Copy code

    public void filterTest() throws Throwable{

           //register channel
           LrJposChannel.setName("MyProduct-JposChannel");

            //creating filter
            ChannelInfoFilter filter = new ChannelInfoFilter();
            Properties props = new Properties();
            props.put("channel-name","47");        //" MyProduct-JposChannel " will be set in field 47
            props.put("socket-info", "48");        //socket info will be set in field 48
            filter.setConfiguration(new SimpleConfiguration(props));

            //adding filter to channel
            LrJposChannel.addFilter(filter);
            //        LrJposChannel.addIncomingFilter(filter);
            //        LrJposChannel.addOutgoingFilter(filter);

            LrISOMsg m = new LrISOMsg();
            m.setMTI("0100");
            m.set(2, "1234567890000000000");
            m.set(3, "523456");
            m.set(4, "123456789121");
            m.set(12, "20241605108110");

            LrJposChannel.send(m);

            LrISOMsg r = LrJposChannel.receive();

            LrJposChannel.removeFilter(filter);
            //        LrJposChannel.removeIncomingFilter(filter);
            //        LrJposChannel.removeOutgoingFilter(filter);
    }

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: