generated from mingliqiye/lib-tem
This commit is contained in:
parent
d3596154bc
commit
0d420d57f2
@ -1,5 +1,5 @@
|
||||
GROUPSID=com.mingliqiye
|
||||
ARTIFACTID=socket-utilts
|
||||
VERSIONS=1.0.4
|
||||
VERSIONS=1.0.6
|
||||
MAINCLASS=com.mingliqiye.Main
|
||||
JDKVERSIONS=1.8
|
||||
|
@ -6,7 +6,7 @@ import java.net.ServerSocket;
|
||||
|
||||
public class DefTcpServerImplementation extends TcpServerImplementation {
|
||||
|
||||
boolean connect(TcpSocketClient client, String id) {
|
||||
public boolean connect(TcpSocketClient client, String id) {
|
||||
System.out.println(
|
||||
StringUtil.format(
|
||||
"客户端 {} ID={} 连接成功",
|
||||
@ -17,7 +17,7 @@ public class DefTcpServerImplementation extends TcpServerImplementation {
|
||||
return true;
|
||||
}
|
||||
|
||||
void disconnect(TcpSocketClient client, String id) {
|
||||
public void disconnect(TcpSocketClient client, String id) {
|
||||
System.out.println(
|
||||
StringUtil.format(
|
||||
"客户端 {} ID={} 断开连接",
|
||||
@ -27,7 +27,7 @@ public class DefTcpServerImplementation extends TcpServerImplementation {
|
||||
);
|
||||
}
|
||||
|
||||
void reception(
|
||||
public void reception(
|
||||
TcpSocketClient client,
|
||||
BufferBytesEntity bufferBytesEntity
|
||||
) {
|
||||
@ -46,7 +46,7 @@ public class DefTcpServerImplementation extends TcpServerImplementation {
|
||||
);
|
||||
}
|
||||
|
||||
void started(ServerSocket serverSocket) {
|
||||
public void started(ServerSocket serverSocket) {
|
||||
System.out.println(
|
||||
StringUtil.format(
|
||||
"服务器启动 监听 {}",
|
||||
@ -57,7 +57,7 @@ public class DefTcpServerImplementation extends TcpServerImplementation {
|
||||
);
|
||||
}
|
||||
|
||||
void closed() {
|
||||
public void closed() {
|
||||
System.out.println("服务器已经关闭");
|
||||
}
|
||||
}
|
||||
|
@ -14,21 +14,21 @@ public abstract class TcpServerImplementation {
|
||||
* @param id 客户端ID
|
||||
* @return 是否允许连接
|
||||
*/
|
||||
abstract boolean connect(TcpSocketClient client, String id);
|
||||
public abstract boolean connect(TcpSocketClient client, String id);
|
||||
|
||||
/**
|
||||
* 断开连接回调函数
|
||||
* @param client 客户端
|
||||
* @param id 客户端ID
|
||||
*/
|
||||
abstract void disconnect(TcpSocketClient client, String id);
|
||||
public abstract void disconnect(TcpSocketClient client, String id);
|
||||
|
||||
abstract void reception(
|
||||
public abstract void reception(
|
||||
TcpSocketClient client,
|
||||
BufferBytesEntity bufferBytesEntity
|
||||
);
|
||||
|
||||
abstract void started(ServerSocket serverSocket);
|
||||
public abstract void started(ServerSocket serverSocket);
|
||||
|
||||
abstract void closed();
|
||||
public abstract void closed();
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class TcpSocketServer extends Thread implements AutoCloseable {
|
||||
);
|
||||
if (!tcpServerImplementation.connect(tcpSocketClient, uuid)) {
|
||||
tcpSocketClient.close();
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
clientMap.put(uuid, tcpSocketClient);
|
||||
tcpSocketClient.start();
|
||||
|
Loading…
x
Reference in New Issue
Block a user