Commit 21468eb163eacee3220f674340283b51c4b44694
1 parent
279e4b707d
Exists in
master
and in
8 other branches
nio server
Showing 1 changed file with 6 additions and 2 deletions
platform-operate-api/src/main/java/com/lyms/hospitalapi/NIOServer.java
View file @
21468eb
| ... | ... | @@ -112,8 +112,12 @@ |
| 112 | 112 | return 0; |
| 113 | 113 | } |
| 114 | 114 | System.out.println("服务端收到信息:" + msg); |
| 115 | - ByteBuffer outBuffer = ByteBuffer.wrap("success".getBytes()); | |
| 116 | - channel.write(outBuffer);// 将消息回送给客户端 | |
| 115 | + if ("exit".equals(msg)) { | |
| 116 | + channel.close(); | |
| 117 | + } else { | |
| 118 | + ByteBuffer outBuffer = ByteBuffer.wrap("success".getBytes()); | |
| 119 | + channel.write(outBuffer);// 将消息回送给客户端 | |
| 120 | + } | |
| 117 | 121 | return msg.length(); |
| 118 | 122 | } catch (Exception e) { |
| 119 | 123 | e.printStackTrace(); |