link.jfire.socket.socketserver.transfer.server.ServerConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jfire-socket Show documentation
Show all versions of jfire-socket Show documentation
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.transfer.server;
import link.jfire.baseutil.collection.set.LightSet;
import link.jfire.socket.socketserver.util.DefaultHeadFactory;
import link.jfire.socket.socketserver.util.HeadFactory;
/**
* 服务器的配置类,用以配置初始化服务器的信息。
* 其中默认读取超时为3秒,空闲等待为30秒
*
* @author 林斌([email protected])
*
*/
public class ServerConfig
{
private byte[] privateKey;
// 链接空闲时的等待时间,默认为30秒
private long waitTimeout = 30000;
// 读取超时时间,默认为3秒
private long readTiemout = 3000;
// 服务器的启动端口
private int port;
private LightSet packageNamesSet = new LightSet<>();
private HeadFactory headFactory = new DefaultHeadFactory();
private boolean activeAuth = false;
public long getWaitTimeout()
{
return waitTimeout;
}
public void setWaitTimeout(long waitTimeout)
{
this.waitTimeout = waitTimeout;
}
public long getReadTiemout()
{
return readTiemout;
}
public void setReadTiemout(long readTiemout)
{
this.readTiemout = readTiemout;
}
public int getPort()
{
return port;
}
public void setPort(int port)
{
if (port < 0 || port > 63355)
{
throw new RuntimeException("设定的端口号异常,超出了系统范围");
}
this.port = port;
}
public String[] getPackageNames()
{
return packageNamesSet.toArray(String.class);
}
public byte[] getPrivateKey()
{
return privateKey;
}
public void setPrivateKey(byte[] privateKey)
{
this.privateKey = privateKey;
}
/**
* 设置包路径
*
* @param packageNames
*/
public void setPackageNames(String... packageNames)
{
packageNamesSet.removeAll();
packageNamesSet.addAll(packageNames);
}
/**
* 增加包路径
*
* @param packageNames
*/
public void addPackageNames(String... packageNames)
{
packageNamesSet.addAll(packageNames);
}
/**
* 设置报文头部的生成和验证工厂类
*
* @param headFactory
* @author windfire([email protected])
*/
public void setHeadFactory(HeadFactory headFactory)
{
this.headFactory = headFactory;
}
public HeadFactory getHeadFactory()
{
return headFactory;
}
public void activeAuth()
{
activeAuth = true;
}
public boolean isActiveAuth()
{
return activeAuth;
}
}