删除用户时如果用户在线则注销用户;去除日志;
This commit is contained in:
parent
1e0b1c6297
commit
704bdf018b
@ -15,8 +15,6 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
|
||||
import io.netty.handler.logging.LogLevel;
|
||||
import io.netty.handler.logging.LoggingHandler;
|
||||
import io.netty.util.concurrent.DefaultPromise;
|
||||
import io.netty.util.concurrent.Promise;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -101,7 +99,6 @@ public class CommunicateService {
|
||||
protected void initChannel(NioSocketChannel ch) {
|
||||
ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(10000000, 4, 4));
|
||||
ch.pipeline().addLast(new MessageCodec());
|
||||
ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
|
||||
ch.pipeline().addLast(new MyChannelInBoundHandlerAdapter());
|
||||
}}).bind(7777);
|
||||
this.webSocketService = webSocketService;
|
||||
|
||||
@ -220,6 +220,7 @@ public class UserService {
|
||||
FileUtil.del(customConfigurationMapper.selectValue(CustomConfigurationMapper.PATH) + user.getStoragePath());
|
||||
} else {
|
||||
FileOperateMessage fileOperateMessage = new FileOperateMessage();
|
||||
fileOperateMessage.setUserid(1);
|
||||
fileOperateMessage.deleteFiles(new String[]{user.getStoragePath()});
|
||||
communicateService.sendMessageToSite(user.getSiteId(), fileOperateMessage);
|
||||
}
|
||||
@ -228,6 +229,8 @@ public class UserService {
|
||||
site.setAvailableSpace(site.getAvailableSpace() + user.getTotalSpace());
|
||||
siteMapper.updateSite(site);
|
||||
userMapper.deleteUser(userid);
|
||||
if(communicateService.userid2user.containsKey(userid)) //删除用户在线
|
||||
logout(userid);
|
||||
|
||||
return response.success("移除用户成功,服务器" + site.getHostname() + "释放" + CustomUtil.fileSizeToString(user.getTotalSpace())).toJSONString();
|
||||
}
|
||||
@ -265,7 +268,6 @@ public class UserService {
|
||||
}
|
||||
|
||||
public void logout(String sessionId){
|
||||
sessionId = sessionId.substring(0, 8);
|
||||
User user = communicateService.interceptor.sessionId2user.get(sessionId);
|
||||
if(user == null)
|
||||
return;
|
||||
@ -284,6 +286,12 @@ public class UserService {
|
||||
communicateService.webSocketService.kickUser(user.getId());
|
||||
}
|
||||
|
||||
public void logout(int userid){
|
||||
HttpSession httpSession = communicateService.userid2httpSession.get(userid);
|
||||
String sessionId = (String) httpSession.getAttribute("sessionId");
|
||||
logout(sessionId);
|
||||
}
|
||||
|
||||
public String alterPasscode(int userid, String passcode) {
|
||||
Response response = new Response();
|
||||
User user = userMapper.selectUserById(userid);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: org.sqlite.JDBC
|
||||
# url: jdbc:sqlite:D:\WorkSpace\code\Java\scalable-network-storage\src\main\resources\sns.db
|
||||
url: jdbc:sqlite:sns.db
|
||||
|
||||
servlet:
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user