diff --git a/LapTrinhMang_FTPSimulator/src/components/ListenThread.java b/LapTrinhMang_FTPSimulator/src/components/ListenThread.java
index c8af984..24ac3d9 100644
--- a/LapTrinhMang_FTPSimulator/src/components/ListenThread.java
+++ b/LapTrinhMang_FTPSimulator/src/components/ListenThread.java
@@ -430,7 +430,10 @@ public void run() {
System.out.println("Client[port " + getSocket().getPort() + "] said: " + message);
Files filesInfo = (Files) request.getObject();
FileEvent fileEvent = (FileEvent) request.getFileUpload();
+
new FileBLL().insertNewFile(filesInfo);
+
+ // convert byte sang file -> lại file lưu trên server
saveFile(fileEvent);
break;
}
@@ -602,6 +605,16 @@ public void run() {
}
//
+ //
+ case "FETCH_USERS": {
+ System.out.println("Client[port " + getSocket().getPort() + "] said: " + message);
+ String authenEmail = (String) request.getObject();
+ List listUsers = new UserBLL().getAllUser();
+ response("fetch_users_success", new HandleResult(listUsers));
+ break;
+ }
+ //
+
default: {
System.out.println("Client[port " + getSocket().getPort() + "] said default: " + message);
response("test", "test");
diff --git a/LapTrinhMang_FTPSimulator/src/components/Server.java b/LapTrinhMang_FTPSimulator/src/components/Server.java
index 9c883f6..aadab31 100644
--- a/LapTrinhMang_FTPSimulator/src/components/Server.java
+++ b/LapTrinhMang_FTPSimulator/src/components/Server.java
@@ -43,6 +43,7 @@ public class Server {
// }
// }
//
+
private static ExecutorService executor;
private static ServerSocket serverSocket;
private static int port;
@@ -59,8 +60,9 @@ public static void Start() {
System.out.println("Server is waiting for client on port " + port
+ "...");
- executor = Executors.newFixedThreadPool(10);
+ executor = Executors.newFixedThreadPool(100); // giới hạn 10 client
executor.execute(new ServerUI());
+
listenClientConnect();
} catch (IOException ex) {
System.err.println("Server socket xảy ra lỗi khi khởi tạo" + ex);
@@ -92,10 +94,12 @@ private static void listenClientConnect() {
//------------------- DANH SÁCH CLIENT CONNECT TỚI SERVER ----------------
public static void registerClient(ListenThread listenThread) {
list_Client.add(listenThread);
+ System.out.println("Total client connect: " + list_Client.size());
}
public static void removeClientDisconnect(ListenThread listenThread) {
list_Client.remove(listenThread);
+ System.out.println("Total client connect: " + list_Client.size());
}
public static ArrayList getListClient() {
diff --git a/LapTrinhMang_FTPSimulator/src/middlewares/HandleVerify.java b/LapTrinhMang_FTPSimulator/src/middlewares/HandleVerify.java
index 41d36ba..34b5afb 100644
--- a/LapTrinhMang_FTPSimulator/src/middlewares/HandleVerify.java
+++ b/LapTrinhMang_FTPSimulator/src/middlewares/HandleVerify.java
@@ -38,6 +38,7 @@ public static HandleResult verifyRegisterUser(Users user) {
if (!existedEmail(user.getEmail())) {
int verifyCode = ThreadRandoms.generateCode(); // random ra 1 verify code
try {
+ // 1. mã code , 2. MailSender
new SendMail(verifyCode, new MailSender(user.getEmail()));
return new HandleResult(true, "Một mã xác thực vừa được gửi đến email của bạn!!!", verifyCode);
} catch (Exception ex) {
@@ -50,7 +51,7 @@ public static HandleResult verifyRegisterUser(Users user) {
}
return new HandleResult(false, "Họ và tên không được bỏ trống!!!");
}
- return new HandleResult(false, "Tối thiểu tám ký tự.\nÍt nhất một chữ cái , một số, một ký tự in hoa, một ký tự đặc biệt (nếu có)!!!");
+ return new HandleResult(false, "Tối thiểu 8 ký tự.\nÍt nhất một chữ cái , một số, một ký tự in hoa, một ký tự đặc biệt (nếu có)!!!");
}
return new HandleResult(false, "Không được phép sử dụng email có tiền tố là anonymous!!!");
}
diff --git a/LapTrinhMang_FTPSimulator/src/models/HandleResult.java b/LapTrinhMang_FTPSimulator/src/models/HandleResult.java
index d8d55f0..702df9f 100644
--- a/LapTrinhMang_FTPSimulator/src/models/HandleResult.java
+++ b/LapTrinhMang_FTPSimulator/src/models/HandleResult.java
@@ -27,12 +27,13 @@ public class HandleResult implements Serializable {
private List ListPermissionses;
private List ListFileShared;
private List ListFolderShared;
+ private List ListUsers;
@SuppressWarnings("unchecked")
//
// 4 tham số: IsSuccessed - Message - User - Folder
public HandleResult(boolean IsSuccessed, String Message, Users User,
- Folders Folder) {
+ Folders Folder) {
this.IsSuccessed = IsSuccessed;
this.Message = Message;
this.User = User;
@@ -47,8 +48,8 @@ public HandleResult(List ListFolderChild, List ListFile) {
// 3 tham số: ListFileShareses - ListFolderShareses - ListPermissionses
public HandleResult(List ListFileShared, List ListFolderShared,
- List ListFileShareses, List ListFolderShareses,
- List ListPermissionses) {
+ List ListFileShareses, List ListFolderShareses,
+ List ListPermissionses) {
this.ListFileShared = ListFileShared;
this.ListFolderShared = ListFolderShared;
this.ListFileShareses = ListFileShareses;
@@ -80,6 +81,11 @@ public HandleResult(boolean IsSuccessed, String Message) {
public HandleResult(boolean IsSuccessed) {
this.IsSuccessed = IsSuccessed;
}
+
+ // fetch Users
+ public HandleResult(List listUsers){
+ this.ListUsers = listUsers;
+ }
@SuppressWarnings("unchecked")
//
@@ -88,6 +94,14 @@ public List getListPermissionses() {
return ListPermissionses;
}
+ public List getListUsers() {
+ return ListUsers;
+ }
+
+ public void setListUsers(List ListUsers) {
+ this.ListUsers = ListUsers;
+ }
+
public List getListFileShared() {
return ListFileShared;
}