Compare commits
3 Commits
5431a7cfb7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a77e0f9396 | ||
|
|
d41b918f59 | ||
|
|
87cbfbd506 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -37,3 +37,6 @@ build/
|
|||||||
|
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
*.log
|
||||||
|
*.db
|
||||||
19
pom.xml
19
pom.xml
@@ -33,6 +33,25 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mindrot</groupId>
|
||||||
|
<artifactId>jbcrypt</artifactId>
|
||||||
|
<version>0.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Server -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xerial</groupId>
|
||||||
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
|
<version>3.51.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Client -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.googlecode.lanterna</groupId>
|
||||||
|
<artifactId>lanterna</artifactId>
|
||||||
|
<version>3.1.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.net.ServerSocket;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
|
|
||||||
public class ChatServer implements Runnable {
|
|
||||||
private int port = 9000;
|
|
||||||
private ServerSocket serverSocket;
|
|
||||||
private ArrayList<Socket> clientSockets = new ArrayList<Socket>();
|
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
public ChatServer() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatServer(int port) {
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerSocket getServerSocket() {
|
|
||||||
return serverSocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
private User getOrCreateUser(String username) {
|
|
||||||
return new User(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SendMessage(User user, String msg) {
|
|
||||||
try {
|
|
||||||
for (Socket client : clientSockets) {
|
|
||||||
PrintWriter out = new PrintWriter(client.getOutputStream(), true);
|
|
||||||
|
|
||||||
out.println(user.getUsername() + " " + msg);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleClient(Socket socket) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
String msg;
|
|
||||||
User user = null;
|
|
||||||
|
|
||||||
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
|
||||||
|
|
||||||
out.println("Login: /login username");
|
|
||||||
while ((msg = in.readLine()) != null) {
|
|
||||||
if (user != null) {
|
|
||||||
SendMessage(user, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
if (msg.toLowerCase().startsWith("/login")) {
|
|
||||||
String username = msg.substring(6).strip();
|
|
||||||
user = getOrCreateUser(username);
|
|
||||||
clientSockets.add(socket);
|
|
||||||
logger.info("Client sie połączył");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
clientSockets.remove(socket);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
serverSocket = new ServerSocket(port);
|
|
||||||
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
Socket clientSocket = serverSocket.accept();
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> handleClient(clientSocket));
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
public class Main {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
ChatServer chatServer = new ChatServer(9000);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Thread serverThread = new Thread(chatServer);
|
|
||||||
serverThread.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
17
src/main/java/auth/PasswordService.java
Normal file
17
src/main/java/auth/PasswordService.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package auth;
|
||||||
|
|
||||||
|
import org.mindrot.jbcrypt.BCrypt;
|
||||||
|
|
||||||
|
public class PasswordService {
|
||||||
|
|
||||||
|
public static String hashPassword(String password) {
|
||||||
|
String salt = BCrypt.gensalt(12);
|
||||||
|
|
||||||
|
return BCrypt.hashpw(password, salt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean comparePassword(String password, String hashPassword) {
|
||||||
|
return BCrypt.checkpw(password, hashPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package client;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
159
src/main/java/server/ChatServer.java
Normal file
159
src/main/java/server/ChatServer.java
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
package server;
|
||||||
|
|
||||||
|
import auth.PasswordService;
|
||||||
|
import user.User;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import user.UserController;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.net.ServerSocket;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class ChatServer implements Runnable {
|
||||||
|
private static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
private int port = 9000;
|
||||||
|
private ServerSocket serverSocket;
|
||||||
|
private UserController controller;
|
||||||
|
private ArrayList<Socket> clientSockets = new ArrayList<Socket>();
|
||||||
|
|
||||||
|
public ChatServer(int port, UserController userController) {
|
||||||
|
this.port = port;
|
||||||
|
this.controller = userController;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerSocket getServerSocket() {
|
||||||
|
return serverSocket;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendMessage(User user, String msg) {
|
||||||
|
try {
|
||||||
|
for (Socket client : clientSockets) {
|
||||||
|
PrintWriter out = new PrintWriter(client.getOutputStream(), true);
|
||||||
|
|
||||||
|
out.println(user.getUsername() + " " + msg);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleClient(Socket socket) {
|
||||||
|
try {
|
||||||
|
String msg;
|
||||||
|
User user = null;
|
||||||
|
|
||||||
|
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||||
|
|
||||||
|
while ((msg = in.readLine()) != null) {
|
||||||
|
if (msg.toLowerCase().startsWith("/")) {
|
||||||
|
ArrayList<String> result = new ArrayList<>();
|
||||||
|
String[] data = msg.toLowerCase().replace("/", "").split(" ");
|
||||||
|
String path = data[0];
|
||||||
|
String[] restArray = Arrays.copyOfRange(data, 1, data.length);
|
||||||
|
|
||||||
|
switch (path) {
|
||||||
|
case "login":
|
||||||
|
if (user != null) {
|
||||||
|
result.add("You are already logged in");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (restArray.length == 2) {
|
||||||
|
String username = restArray[0];
|
||||||
|
String password = restArray[1];
|
||||||
|
|
||||||
|
Optional<User> userOptional = controller.getUser(username, password);
|
||||||
|
|
||||||
|
if (userOptional.isPresent()) {
|
||||||
|
user = userOptional.get();
|
||||||
|
clientSockets.add(socket);
|
||||||
|
} else {
|
||||||
|
result.add("Login failed. Please enter the correct password!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.add("Login failed. Please enter the correct password!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "register":
|
||||||
|
if (user != null) {
|
||||||
|
result.add("You are already logged in");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (restArray.length == 2) {
|
||||||
|
String username = restArray[0];
|
||||||
|
String password = restArray[1];
|
||||||
|
|
||||||
|
Optional<User> userOptional = controller.createUser(username, password);
|
||||||
|
|
||||||
|
if (userOptional.isPresent()) {
|
||||||
|
user = userOptional.get();
|
||||||
|
clientSockets.add(socket);
|
||||||
|
} else {
|
||||||
|
result.add("Register failed. Please enter the correct password!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
result.add("Register failed. Please enter the correct password!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "logout":
|
||||||
|
user = null;
|
||||||
|
clientSockets.remove(socket);
|
||||||
|
result.add("You have been logged out");
|
||||||
|
break;
|
||||||
|
case "help":
|
||||||
|
result.add("/login - Login into your account, example: /login Janek Password123");
|
||||||
|
result.add("/register - Create an account, example: /register Olek Password321");
|
||||||
|
result.add("/logout - logout account");
|
||||||
|
break;
|
||||||
|
case null, default:
|
||||||
|
result.add("Invalid command!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
result.forEach(out::println);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (user != null) {
|
||||||
|
SendMessage(user, msg);
|
||||||
|
} else {
|
||||||
|
out.println("Please login or register...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
clientSockets.remove(socket);
|
||||||
|
logger.error(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
serverSocket = new ServerSocket(port);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
Socket clientSocket = serverSocket.accept();
|
||||||
|
|
||||||
|
Thread thread = new Thread(() -> handleClient(clientSocket));
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main/java/server/Main.java
Normal file
25
src/main/java/server/Main.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package server;
|
||||||
|
|
||||||
|
import user.UserController;
|
||||||
|
import user.UserDao;
|
||||||
|
import user.UserService;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static UserController init() {
|
||||||
|
UserDao userDao = new UserDao();
|
||||||
|
UserService userService = new UserService(userDao);
|
||||||
|
UserController userController = new UserController(userService);
|
||||||
|
|
||||||
|
return userController;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
UserController userController = init();
|
||||||
|
|
||||||
|
ChatServer chatServer = new ChatServer(9000, userController);
|
||||||
|
Thread serverThread = new Thread(chatServer, "chat-server");
|
||||||
|
serverThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
public class User {
|
package user;
|
||||||
|
|
||||||
|
public class User {
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
public User(String username) {
|
public User(String username) {
|
||||||
@@ -13,4 +14,11 @@ public class User {
|
|||||||
public void setUsername(String username) {
|
public void setUsername(String username) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "User{" +
|
||||||
|
"username='" + username + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
26
src/main/java/user/UserController.java
Normal file
26
src/main/java/user/UserController.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package user;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
private UserService service;
|
||||||
|
|
||||||
|
public UserController(UserService service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<User> createUser(
|
||||||
|
String username,
|
||||||
|
String password
|
||||||
|
) {
|
||||||
|
return service.createUser(username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<User> getUser(
|
||||||
|
String username,
|
||||||
|
String password
|
||||||
|
) {
|
||||||
|
return service.getUser(username, password);
|
||||||
|
}
|
||||||
|
}
|
||||||
103
src/main/java/user/UserDao.java
Normal file
103
src/main/java/user/UserDao.java
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
package user;
|
||||||
|
|
||||||
|
import auth.PasswordService;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class UserDao {
|
||||||
|
public static final String DRIVER = "org.sqlite.JDBC";
|
||||||
|
public static final String DB_URL = "jdbc:sqlite:chat.db";
|
||||||
|
|
||||||
|
private Connection conn;
|
||||||
|
private Statement stat;
|
||||||
|
|
||||||
|
public UserDao() {
|
||||||
|
try {
|
||||||
|
conn = DriverManager.getConnection(DB_URL);
|
||||||
|
stat = conn.createStatement();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
createTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean createTables() {
|
||||||
|
String createUsers = "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, username VARCHAR(255) UNIQUE, password VARCHAR(255) )";
|
||||||
|
try {
|
||||||
|
stat.execute(createUsers);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean checkIfUsernameExists(String username) {
|
||||||
|
try {
|
||||||
|
PreparedStatement preparedStatement = conn.prepareStatement(
|
||||||
|
"SELECT * FROM users WHERE username=(?);"
|
||||||
|
);
|
||||||
|
|
||||||
|
preparedStatement.setString(1, username);
|
||||||
|
ResultSet result = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (result.next()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Optional<User> insertUser(String username, String password) {
|
||||||
|
try {
|
||||||
|
String hashPassword = PasswordService.hashPassword(password);
|
||||||
|
PreparedStatement preparedStatement = conn.prepareStatement(
|
||||||
|
"INSERT INTO users VALUES (NULL, ?, ?);"
|
||||||
|
);
|
||||||
|
|
||||||
|
preparedStatement.setString(1, username);
|
||||||
|
preparedStatement.setString(2, hashPassword);
|
||||||
|
preparedStatement.execute();
|
||||||
|
|
||||||
|
User user = new User(username);
|
||||||
|
return Optional.of(user);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<User> getUser(String username, String password) {
|
||||||
|
try {
|
||||||
|
PreparedStatement preparedStatement = conn.prepareStatement(
|
||||||
|
"SELECT * FROM users WHERE username=(?);"
|
||||||
|
);
|
||||||
|
|
||||||
|
preparedStatement.setString(1, username);
|
||||||
|
ResultSet result = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
String passwordFromDB;
|
||||||
|
while (result.next()) {
|
||||||
|
passwordFromDB = result.getString("password");
|
||||||
|
|
||||||
|
if (PasswordService.comparePassword(password, passwordFromDB)) {
|
||||||
|
return Optional.of(new User(username));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
46
src/main/java/user/UserService.java
Normal file
46
src/main/java/user/UserService.java
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package user;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class UserService {
|
||||||
|
private static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
private UserDao userDao;
|
||||||
|
|
||||||
|
public UserService(UserDao userDao) {
|
||||||
|
this.userDao = userDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<User> createUser(
|
||||||
|
String username,
|
||||||
|
String pass
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (!userDao.checkIfUsernameExists(username)) {
|
||||||
|
return userDao.insertUser(username, pass);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error creating user: {}", e.toString());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<User> getUser(
|
||||||
|
String username,
|
||||||
|
String pass
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
return userDao.getUser(username, pass);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while login into user: {}", e.toString());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<Console name="Console" target="SYSTEM_OUT">
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||||
</Console>
|
</Console>
|
||||||
<File name="File" fileName="all.log" immediateFlush="true" append="true" >
|
<File name="File" fileName="logs/all.log" immediateFlush="true" append="true" >
|
||||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||||
</File>
|
</File>
|
||||||
</Appenders>
|
</Appenders>
|
||||||
|
|||||||
@@ -1,12 +1,27 @@
|
|||||||
|
import server.ChatServer;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import user.UserController;
|
||||||
|
import user.UserDao;
|
||||||
|
import user.UserService;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class ChatServerTest {
|
public class ChatServerTest {
|
||||||
|
|
||||||
|
public static UserController init() {
|
||||||
|
UserDao userDao = new UserDao();
|
||||||
|
UserService userService = new UserService(userDao);
|
||||||
|
UserController userController = new UserController(userService);
|
||||||
|
|
||||||
|
return userController;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void checkIfServerUp() throws Exception {
|
void checkIfServerUp() throws Exception {
|
||||||
ChatServer chatServer = new ChatServer(0);
|
// Fixme: Powinno sie to odnosić na inną baze danych.
|
||||||
|
UserController controller = init();
|
||||||
|
|
||||||
|
ChatServer chatServer = new ChatServer(0, controller);
|
||||||
|
|
||||||
Thread serverThread = new Thread(chatServer);
|
Thread serverThread = new Thread(chatServer);
|
||||||
serverThread.start();
|
serverThread.start();
|
||||||
|
|||||||
Reference in New Issue
Block a user