All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.sdk.nio.channeling.ChannelingEagerSocketFeature Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.sdk.nio.channeling;

import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.util.Set;

public class ChannelingEagerSocketFeature implements ChannelingPlugin{

    private final Channeling channeling;

    public ChannelingEagerSocketFeature(Channeling channeling) {
        this.channeling = channeling;
    }

    @Override
    public void checkKeys(Set allKeys) throws IOException {
        if(channeling.noEagerSocket) {
            return;
        }
        for (SelectionKey key : allKeys) {
            ChannelingSocket channelingSocket = (ChannelingSocket) key.attachment();
            if (channelingSocket != null) {

                if (channelingSocket.isEagerRead()) {
                    // If it is force call back, set last process bytes to 0
                    channelingSocket.setLastProcessedBytes(0);
                    channelingSocket.getThen().callback(channelingSocket);
                }
            }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy