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

link.jfire.socket.socketserver.handler.impl.Utf8EchoHandler Maven / Gradle / Ivy

Go to download

Jfire - socket is a server-side framework based on AIO. Users only need a simple implementation of a business logic processing interface can be the business data processing. The framework provides the client and server at the same time. Have strong connection capacity. Single server provides tens of thousands of connections.

The newest version!
package link.jfire.socket.socketserver.handler.impl;

import java.nio.charset.Charset;
import javax.annotation.Resource;
import link.jfire.baseutil.collection.ByteCache;
import link.jfire.baseutil.simplelog.ConsoleLogFactory;
import link.jfire.baseutil.simplelog.Logger;
import link.jfire.socket.socketserver.bus.BusinessCommand;
import link.jfire.socket.socketserver.bus.Message;
import link.jfire.socket.socketserver.handler.MessageHandler;

@Resource
public class Utf8EchoHandler implements MessageHandler
{
    private Logger  logger  = ConsoleLogFactory.getLogger();
    private Charset charset = Charset.forName("utf-8");
    
    @Override
    public byte interestedDataPacketType()
    {
        return BusinessCommand.ECHO;
    }
    
    @Override
    public void handler(Message message)
    {
        ByteCache cache = message.getBusinessData();
        logger.trace("收到的消息是{},消息长度{}", cache.toString(charset), cache.startRead(0).remaining());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy