Ioserver is a lightweight Server framework that imitates Mina. Recently, due to the use of Mina, I have read the source code of ioserver. By the way, I am familiar with j2se NiO.
Ioserver is designed to be a mobile online game server framework. TCP protocol is supported.
The usage of this framework is similar to that of Mina. It has a protocolhandler and iohandler without Mina's filterchain;
The basic process is to create a config, set the port, protocolhandler, and iohandler, and start the server. Very convenient.
Ioserver defines a netmessage class that requires all service classes to implement this interface.
Ioserver has three core classes: ioserviceimpl, ioreadwritemachine, and iosession;
Ioserviceimpl uses NiO to poll serversocket. When there is a new connection on the server port, it receives the connection and creates an iosession;
Ioreadwritemachine uses NiO to poll the client socket of the machine. When a socket has data, it calls the corresponding iosession to read the parsing data. When a socket has data to be sent, call the sending method of the corresponding iosession;
Iosession: Read data and call protocolhandler and iohandler to process the data. When there is data in the cache queue to be sent, send it.
Note:
Relationship between ioserviceimpl and ioreadwritemachine:
Ioserviceimpl is only responsible for processing server ports;
Ioreadwritemachine is managed by ioreadwritemachinemanager. There are several CPUs, just several ioreadwritemachine, And the iosession is evenly allocated to each CPU.