This commit is contained in:
Looly
2023-03-23 23:50:59 +08:00
parent e81a63c6ad
commit c8309ef5fb
57 changed files with 764 additions and 505 deletions

View File

@@ -18,7 +18,7 @@ public class AioServerTest {
@Override
public void accept(final AioSession session) {
StaticLog.debug("【客户端】:{} 连接。", session.getRemoteAddress());
session.write(BufferUtil.createUtf8("=== Welcome to Hutool socket server. ==="));
session.write(BufferUtil.ofUtf8("=== Welcome to Hutool socket server. ==="));
}
@Override
@@ -32,7 +32,7 @@ public class AioServerTest {
.append("Content-Type: text/html; charset=UTF-8\r\n")//
.append("\r\n")
.append("Hello Hutool socket");//
session.writeAndClose(BufferUtil.createUtf8(response));
session.writeAndClose(BufferUtil.ofUtf8(response));
}else {
session.read();
}

View File

@@ -34,8 +34,8 @@ public class NioClientTest {
});
client.listen();
client.write(BufferUtil.createUtf8("你好。\n"));
client.write(BufferUtil.createUtf8("你好2。"));
client.write(BufferUtil.ofUtf8("你好。\n"));
client.write(BufferUtil.ofUtf8("你好2。"));
// 在控制台向服务器端发送数据
Console.log("请输入发送的消息:");
@@ -43,7 +43,7 @@ public class NioClientTest {
while (scanner.hasNextLine()) {
final String request = scanner.nextLine();
if (request != null && request.trim().length() > 0) {
client.write(BufferUtil.createUtf8(request));
client.write(BufferUtil.ofUtf8(request));
}
}
}

View File

@@ -45,6 +45,6 @@ public class NioServerTest {
public static void doWrite(final SocketChannel channel, String response) throws IOException {
response = "收到消息:" + response;
//将缓冲数据写入渠道,返回给客户端
channel.write(BufferUtil.createUtf8(response));
channel.write(BufferUtil.ofUtf8(response));
}
}