# talent-aio **Repository Path**: nanfang/talent-aio ## Basic Information - **Project Name**: talent-aio - **Description**: No description available - **Primary Language**: Unknown - **License**: LGPL-2.1 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2020-06-12 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
|
|
public class HelloServerStarter
{
static ServerGroupContext
public class HelloClientStarter
{
private static String serverIp = null; //服务器的IP地址
private static int serverPort = 0; //服务器的PORT
private static AioClient aioClient;
private static ClientGroupContext clientGroupContext = null;
private static ClientAioHandler aioClientHandler = null;
private static ClientAioListener aioListener = null;
public static String SERVER_IP = "127.0.0.1"; //服务器的IP地址
public static int SERVER_PORT = 9321; //服务器的PORT
public static void main(String[] args) throws Exception
{
serverIp = "127.0.0.1";
serverPort = com.talent.aio.examples.helloworld.common.Const.PORT;
aioClientHandler = new HelloClientAioHandler();
aioListener = null;
clientGroupContext = new ClientGroupContext<>(serverIp, serverPort, aioClientHandler, aioListener);
aioClient = new AioClient<>(clientGroupContext);
String bindIp = null;
int bindPort = 0;
boolean autoReconnect = false; //暂时不支持自动重连,需要业务自己实现,后续版本会支持此属性为true
ClientChannelContext clientChannelContext = aioClient.connect(bindIp, bindPort, autoReconnect);
//以下内容不是启动的过程,而是属于发消息的过程
HelloPacket packet = new HelloPacket();
packet.setBody("hello world".getBytes(HelloPacket.CHARSET));
Aio.send(clientChannelContext, packet);
}
}