Home >Backend Development >PHP Tutorial >Apache Mina study notes (4) - Filters
IoFilter is another core part of MINA. It filters all I/O events and requests for IoService and IoHandler, similar to the servlet filter in the web.
In this tutorial, we will develop a IoFilter in practical examples, usually it is easy to implement, but you may need to know some internal details of MINA.
The following are some existing Filters:
You can inherit IoAdapter instead of directly implementing IoFilter. Unless overridden, any received events will be passed through the following filter:
public class MyFilter extends IoFilterAdapter { @Override public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception { // Some logic here... nextFilter.sessionOpened(session); // Some other logic here... } }
Transforming a Write Request
Be Careful When Filtering sessionCreated Event
Watch out the Empty Buffers !
The above is the content of Apache Mina Study Notes (4) - Filters. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!