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