diff --git a/Chat/.DS_Store b/Chat/.DS_Store
new file mode 100644
index 0000000..9a874b5
Binary files /dev/null and b/Chat/.DS_Store differ
diff --git a/Chat/.idea/.gitignore b/Chat/.idea/.gitignore
new file mode 100644
index 0000000..5c98b42
--- /dev/null
+++ b/Chat/.idea/.gitignore
@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml
\ No newline at end of file
diff --git a/Chat/.idea/description.html b/Chat/.idea/description.html
new file mode 100644
index 0000000..db5f129
--- /dev/null
+++ b/Chat/.idea/description.html
@@ -0,0 +1 @@
+Simple Java application that includes a class with main() method
\ No newline at end of file
diff --git a/Chat/.idea/encodings.xml b/Chat/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/Chat/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/.idea/misc.xml b/Chat/.idea/misc.xml
new file mode 100644
index 0000000..90bd43d
--- /dev/null
+++ b/Chat/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/.idea/modules.xml b/Chat/.idea/modules.xml
new file mode 100644
index 0000000..deff887
--- /dev/null
+++ b/Chat/.idea/modules.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/.idea/project-template.xml b/Chat/.idea/project-template.xml
new file mode 100644
index 0000000..1f08b88
--- /dev/null
+++ b/Chat/.idea/project-template.xml
@@ -0,0 +1,3 @@
+
+ IJ_BASE_PACKAGE
+
\ No newline at end of file
diff --git a/Chat/.idea/uiDesigner.xml b/Chat/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/Chat/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/.idea/vcs.xml b/Chat/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/Chat/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/Chat.iml b/Chat/Chat.iml
new file mode 100644
index 0000000..d5c0743
--- /dev/null
+++ b/Chat/Chat.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Chat/J2_Stream200303.iml b/Chat/J2_Stream200303.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/Chat/J2_Stream200303.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/chat-client/chat-client.iml b/Chat/chat-client/chat-client.iml
new file mode 100644
index 0000000..4ba0082
--- /dev/null
+++ b/Chat/chat-client/chat-client.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/chat-client/src/ru/gb/jt/chat/client/ClientGUI.java b/Chat/chat-client/src/ru/gb/jt/chat/client/ClientGUI.java
new file mode 100644
index 0000000..eb8f385
--- /dev/null
+++ b/Chat/chat-client/src/ru/gb/jt/chat/client/ClientGUI.java
@@ -0,0 +1,257 @@
+package ru.gb.jt.chat.client;
+
+import ru.gb.jt.chat.library.Library;
+import ru.gb.jt.network.SocketThread;
+import ru.gb.jt.network.SocketThreadListener;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.Socket;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Scanner;
+
+public class ClientGUI extends JFrame implements ActionListener, Thread.UncaughtExceptionHandler, SocketThreadListener {
+
+ private static final int WIDTH = 400;
+ private static final int HEIGHT = 300;
+
+ private final JTextArea log = new JTextArea();
+ private final JPanel panelTop = new JPanel(new GridLayout(2, 3));
+ private final JTextField tfIPAddress = new JTextField("127.0.0.1");
+ private final JTextField tfPort = new JTextField("8189");
+ private final JCheckBox cbAlwaysOnTop = new JCheckBox("Always on top");
+ private final JTextField tfLogin = new JTextField("Sla");
+ private final JPasswordField tfPassword = new JPasswordField("123");
+ private final JButton btnLogin = new JButton("Login");
+
+ private final JPanel panelBottom = new JPanel(new BorderLayout());
+ private final JButton btnDisconnect = new JButton("Disconnect");
+ private final JTextField tfMessage = new JTextField();
+ private final JButton btnSend = new JButton("Send");
+
+ private final DateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm:ss: ");
+ private final String WINDOW_TITLE = "Chat";
+
+
+ private final JList userList = new JList<>();
+ private SocketThread socketThread;
+
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new ClientGUI();
+ }
+ });
+ }
+
+ private ClientGUI() {
+ Thread.setDefaultUncaughtExceptionHandler(this);
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ setLocationRelativeTo(null);
+ setSize(WIDTH, HEIGHT);
+ setTitle("Chat client");
+ String[] users = {"user1", "user2", "user3", "user4", "user5",
+ "user_with_an_exceptionally_long_name_in_this_chat"};
+ userList.setListData(users);
+ log.setEditable(false);
+ JScrollPane scrollLog = new JScrollPane(log);
+ JScrollPane scrollUsers = new JScrollPane(userList);
+ scrollUsers.setPreferredSize(new Dimension(100, 0));
+ cbAlwaysOnTop.addActionListener(this);
+ btnSend.addActionListener(this);
+ tfMessage.addActionListener(this);
+ btnLogin.addActionListener(this);
+ btnDisconnect.addActionListener(this);
+
+ panelTop.add(tfIPAddress);
+ panelTop.add(tfPort);
+ panelTop.add(cbAlwaysOnTop);
+ panelTop.add(tfLogin);
+ panelTop.add(tfPassword);
+ panelTop.add(btnLogin);
+ panelBottom.add(btnDisconnect, BorderLayout.WEST);
+ panelBottom.add(tfMessage, BorderLayout.CENTER);
+ panelBottom.add(btnSend, BorderLayout.EAST);
+ panelBottom.setVisible(false);
+
+ add(scrollLog, BorderLayout.CENTER);
+ add(scrollUsers, BorderLayout.EAST);
+ add(panelTop, BorderLayout.NORTH);
+ add(panelBottom, BorderLayout.SOUTH);
+
+ setVisible(true);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object src = e.getSource();
+ if (src == cbAlwaysOnTop) {
+ setAlwaysOnTop(cbAlwaysOnTop.isSelected());
+ } else if (src == btnSend || src == tfMessage) {
+ sendMessage();
+ } else if (src == btnLogin) {
+ connect();
+ } else if (src == btnDisconnect) {
+ socketThread.close();
+ }
+ else
+ throw new RuntimeException("Unknown source: " + src);
+ }
+
+ private void connect() {
+ try {
+ Socket socket = new Socket(tfIPAddress.getText(), Integer.parseInt(tfPort.getText()));
+ socketThread = new SocketThread(this, "Client", socket);
+ } catch (IOException e) {
+ showException(Thread.currentThread(), e);
+ }
+ }
+
+ private void sendMessage() {
+ String msg = tfMessage.getText();
+ if ("".equals(msg)) return;
+ tfMessage.setText(null);
+ tfMessage.grabFocus();
+ socketThread.sendMessage(Library.getTypeBcastClient(msg));
+ // пишем лог в файл
+ wrtMsgToLogFile(msg,tfLogin.getText());
+ }
+
+ private void wrtMsgToLogFile(String msg, String username) {
+ try (FileWriter out = new FileWriter("log.txt", true)) {
+ out.write(username + ": " + msg + "\n");
+ out.flush();
+ } catch (IOException e) {
+ showException(Thread.currentThread(), e);
+ }
+ }
+
+
+
+
+
+ private void outMsgFromLogFile() {
+ try (FileReader in = new FileReader("log.txt")) {
+ Scanner scanner = new Scanner(in);
+
+ while (scanner.hasNextLine()) {
+ String str = scanner.nextLine();
+ socketThread.sendMessage("str");
+ }
+ scanner.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+
+
+
+ private void putLog(String msg) {
+ if ("".equals(msg)) return;
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ log.append(msg + "\n");
+ log.setCaretPosition(log.getDocument().getLength());
+ }
+ });
+ }
+
+ private void showException(Thread t, Throwable e) {
+ String msg;
+ StackTraceElement[] ste = e.getStackTrace();
+ if (ste.length == 0)
+ msg = "Empty Stacktrace";
+ else {
+ msg = "Exception in " + t.getName() + " " +
+ e.getClass().getCanonicalName() + ": " +
+ e.getMessage() + "\n\t at " + ste[0];
+ }
+ JOptionPane.showMessageDialog(null, msg, "Exception", JOptionPane.ERROR_MESSAGE);
+ }
+
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ e.printStackTrace();
+ showException(t, e);
+ System.exit(1);
+ }
+
+ /**
+ * Socket thread methods
+ * */
+
+ @Override
+ public void onSocketStart(SocketThread thread, Socket socket) {
+ putLog("Start");
+ }
+
+ @Override
+ public void onSocketStop(SocketThread thread) {
+ putLog("Stop");
+ panelBottom.setVisible(false);
+ panelTop.setVisible(true);
+ setTitle(WINDOW_TITLE);
+ userList.setListData(new String[0]);
+ }
+
+ @Override
+ public void onSocketReady(SocketThread thread, Socket socket) {
+ putLog("Ready");
+ panelBottom.setVisible(true);
+ panelTop.setVisible(false);
+ String login = tfLogin.getText();
+ String password = new String(tfPassword.getPassword());
+ int p = password.hashCode();
+ thread.sendMessage(Library.getAuthRequest(login, password));
+ // outMsgFromLogFile();
+ }
+
+ @Override
+ public void onReceiveString(SocketThread thread, Socket socket, String msg) {
+ String[] arr = msg.split(Library.DELIMITER);
+ String msgType = arr[0];
+ switch (msgType) {
+ case Library.AUTH_ACCEPT:
+ setTitle(WINDOW_TITLE + " entered with nickname: " + arr[1]);
+ break;
+ case Library.AUTH_DENIED:
+ putLog(msg);
+ break;
+ case Library.MSG_FORMAT_ERROR:
+ putLog(msg);
+ socketThread.close();
+ break;
+ case Library.TYPE_BROADCAST:
+ putLog(DATE_FORMAT.format(Long.parseLong(arr[1])) +
+ arr[2] + ": " + arr[3]);
+ break;
+ case Library.USER_LIST:
+ String users = msg.substring(Library.USER_LIST.length() +
+ Library.DELIMITER.length());
+ String[] usersArr = users.split(Library.DELIMITER);
+ Arrays.sort(usersArr);
+ userList.setListData(usersArr);
+ break;
+ default:
+ throw new RuntimeException("Unknown message type: " + msg);
+ }
+
+ }
+
+ @Override
+ public void onSocketException(SocketThread thread, Exception exception) {
+ //showException(thread, exception);
+ }
+}
diff --git a/Chat/chat-library/chat-library.iml b/Chat/chat-library/chat-library.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/Chat/chat-library/chat-library.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/chat-library/src/ru/gb/jt/chat/library/Library.java b/Chat/chat-library/src/ru/gb/jt/chat/library/Library.java
new file mode 100644
index 0000000..976a1cd
--- /dev/null
+++ b/Chat/chat-library/src/ru/gb/jt/chat/library/Library.java
@@ -0,0 +1,56 @@
+package ru.gb.jt.chat.library;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Scanner;
+
+public class Library {
+ /*
+/auth_request±login±password
+/auth_accept±nickname
+/auth_error
+/broadcast±msg
+/msg_format_error±msg
+/user_list±user1±user2±user3±....
+* */
+ public static final String DELIMITER = "±";
+ public static final String AUTH_REQUEST = "/auth_request";
+ public static final String AUTH_ACCEPT = "/auth_accept";
+ public static final String AUTH_DENIED = "/auth_denied";
+ public static final String MSG_FORMAT_ERROR = "/msg_format_error";
+ // если мы вдруг не поняли, что за сообщение и не смогли разобрать
+ public static final String TYPE_BROADCAST = "/bcast";
+ // то есть сообщение, которое будет посылаться всем
+ public static final String TYPE_BCAST_CLIENT = "/client_msg";
+ public static final String USER_LIST = "/user_list";
+
+ public static String getTypeBcastClient(String msg) {
+ return TYPE_BCAST_CLIENT + DELIMITER + msg;
+ }
+
+ public static String getUserList(String users) {
+ return USER_LIST + DELIMITER + users;
+ }
+
+ public static String getAuthRequest(String login, String password) {
+ return AUTH_REQUEST + DELIMITER + login + DELIMITER + password;
+ }
+
+ public static String getAuthAccept(String nickname) {
+ return AUTH_ACCEPT + DELIMITER + nickname;
+ }
+
+ public static String getAuthDenied() {
+ return AUTH_DENIED;
+ }
+
+ public static String getMsgFormatError(String message) {
+ return MSG_FORMAT_ERROR + DELIMITER + message;
+ }
+
+ public static String getTypeBroadcast(String src, String message) {
+ return TYPE_BROADCAST + DELIMITER + System.currentTimeMillis() +
+ DELIMITER + src + DELIMITER + message;
+ }
+
+}
diff --git a/Chat/chat-server/chat-server.db b/Chat/chat-server/chat-server.db
new file mode 100644
index 0000000..55d295f
Binary files /dev/null and b/Chat/chat-server/chat-server.db differ
diff --git a/Chat/chat-server/chat-server.iml b/Chat/chat-server/chat-server.iml
new file mode 100644
index 0000000..f370ad6
--- /dev/null
+++ b/Chat/chat-server/chat-server.iml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/chat-server/sqlite-jdbc-3.21.0.jar b/Chat/chat-server/sqlite-jdbc-3.21.0.jar
new file mode 100644
index 0000000..56b627d
Binary files /dev/null and b/Chat/chat-server/sqlite-jdbc-3.21.0.jar differ
diff --git a/Chat/chat-server/src/ru/gb/jt/chat/server/core/ChatServer.java b/Chat/chat-server/src/ru/gb/jt/chat/server/core/ChatServer.java
new file mode 100644
index 0000000..a658a86
--- /dev/null
+++ b/Chat/chat-server/src/ru/gb/jt/chat/server/core/ChatServer.java
@@ -0,0 +1,206 @@
+package ru.gb.jt.chat.server.core;
+
+import ru.gb.jt.chat.library.Library;
+import ru.gb.jt.network.ServerSocketThread;
+import ru.gb.jt.network.ServerSocketThreadListener;
+import ru.gb.jt.network.SocketThread;
+import ru.gb.jt.network.SocketThreadListener;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Vector;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class ChatServer implements ServerSocketThreadListener, SocketThreadListener {
+
+ ServerSocketThread server;
+ ChatServerListener listener;
+ private Vector clients = new Vector<>();
+ ExecutorService executorService = Executors.newFixedThreadPool(3);
+ public ChatServer(ChatServerListener listener) {
+ this.listener = listener;
+ }
+
+ public void start(int port) {
+ if (server == null || !server.isAlive()) {
+ server = new ServerSocketThread(this, "Server", port, 2000);
+ } else {
+ putLog("Server already started!");
+ }
+ }
+
+ public void stop() {
+ if (server != null && server.isAlive()) {
+ server.interrupt(); //null.interrupt();
+ } else {
+ putLog("Server is not running");
+ }
+ }
+
+ private void putLog(String msg) {
+ listener.onChatServerMessage(msg);
+ }
+
+ /**
+ * Server Socket Thread methods
+ * */
+
+ @Override
+ public void onServerStart(ServerSocketThread thread) {
+ putLog("Server started");
+ SqlClient.connect();
+ }
+
+ @Override
+ public void onServerStop(ServerSocketThread thread) {
+ putLog("Server stopped");
+ for (int i = 0; i < clients.size(); i++) {
+ clients.get(i).close();
+ }
+ SqlClient.disconnect();
+ }
+
+ @Override
+ public void onServerSocketCreated(ServerSocketThread thread, ServerSocket server) {
+ putLog("Server socket created");
+ }
+
+ @Override
+ public void onServerTimeout(ServerSocketThread thread, ServerSocket server) { }
+
+ @Override
+ public void onSocketAccepted(ServerSocketThread thread, ServerSocket server, Socket socket) {
+
+ putLog("Client connected");
+ String name = "Socket Thread " + socket.getInetAddress() + ":" + socket.getPort();
+
+
+ //после получения запроса на подключение сервер создаёт сокет
+ // для общения с клиентом и отправляет его в отдельный поток
+
+ executorService.execute(new ClientThread(this, name, socket));
+ }
+
+
+ @Override
+ public void onServerException(ServerSocketThread thread, Throwable exception) {
+ exception.printStackTrace();
+ }
+
+ /**
+ * Socket Thread methods
+ * */
+
+ @Override
+ public synchronized void onSocketStart(SocketThread thread, Socket socket) {
+ putLog("Client connected");
+ }
+
+ @Override
+ public synchronized void onSocketStop(SocketThread thread) {
+ ClientThread client = (ClientThread) thread;
+ clients.remove(thread);
+
+ // закрытие пула потоков
+ executorService.shutdown();
+
+
+ if (client.isAuthorized() && !client.isReconnected()) {
+ sendToAllAuthorizedClients(Library.getTypeBroadcast("Server",
+ client.getNickname() + " disconnected"));
+ }
+ sendToAllAuthorizedClients(Library.getUserList(getUsers()));
+
+ }
+
+ @Override
+ public synchronized void onSocketReady(SocketThread thread, Socket socket) {
+ putLog("Client is ready to chat");
+ clients.add(thread);
+ }
+
+ @Override
+ public synchronized void onReceiveString(SocketThread thread, Socket socket, String msg) {
+ ClientThread client = (ClientThread) thread;
+ if (client.isAuthorized()) {
+ handleAutorizedMessage(client, msg);
+ } else {
+ handleNonAuthorizedMessage(client, msg);
+ }
+ }
+
+ @Override
+ public synchronized void onSocketException(SocketThread thread, Exception exception) {
+ exception.printStackTrace();
+ }
+
+ private void handleNonAuthorizedMessage(ClientThread client, String msg) {
+// /auth_request±login±password
+ String[] arr = msg.split(Library.DELIMITER);
+ if (arr.length != 3 || !arr[0].equals(Library.AUTH_REQUEST)) {
+ client.msgFormatError(msg);
+ return;
+ }
+ String login = arr[1];
+ String password = arr[2];
+ String nickname = SqlClient.getNickname(login, password);
+ if (nickname == null) {
+ putLog("Invalid credentials for user" + login);
+ client.authFail();
+ return;
+ } else {
+ ClientThread oldClient = findClientByNickname(nickname);
+ client.authAccept(nickname);
+ if (oldClient == null) {
+ sendToAllAuthorizedClients(Library.getTypeBroadcast("Server", nickname + " connected"));
+ } else {
+ oldClient.reconnect();
+ clients.remove(oldClient);
+ }
+ }
+ sendToAllAuthorizedClients(Library.getUserList(getUsers()));
+ }
+
+ private void handleAutorizedMessage(ClientThread client, String msg) {
+ String[] arr = msg.split(Library.DELIMITER);
+ String msgType = arr[0];
+ switch (msgType) {
+ case Library.TYPE_BCAST_CLIENT:
+ sendToAllAuthorizedClients(
+ Library.getTypeBroadcast(client.getNickname(), arr[1]));
+ break;
+ default:
+ client.sendMessage(Library.getMsgFormatError(msg));
+ }
+ }
+
+ private synchronized void sendToAllAuthorizedClients(String msg) {
+ for (int i = 0; i < clients.size(); i++) {
+ ClientThread client = (ClientThread) clients.get(i);
+ if (!client.isAuthorized()) continue;
+ client.sendMessage(msg);
+ }
+ }
+
+ private synchronized String getUsers() {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < clients.size(); i++) {
+ ClientThread client = (ClientThread) clients.get(i);
+ if (!client.isAuthorized()) continue;
+ sb.append(client.getNickname()).append(Library.DELIMITER);
+ }
+ return sb.toString();
+ }
+
+ private synchronized ClientThread findClientByNickname(String nickname) {
+ for (int i = 0; i < clients.size(); i++) {
+ ClientThread client = (ClientThread) clients.get(i);
+ if (!client.isAuthorized()) continue;
+ if (client.getNickname().equals(nickname))
+ return client;
+ }
+ return null;
+ }
+
+}
diff --git a/Chat/chat-server/src/ru/gb/jt/chat/server/core/ChatServerListener.java b/Chat/chat-server/src/ru/gb/jt/chat/server/core/ChatServerListener.java
new file mode 100644
index 0000000..d7c35bc
--- /dev/null
+++ b/Chat/chat-server/src/ru/gb/jt/chat/server/core/ChatServerListener.java
@@ -0,0 +1,5 @@
+package ru.gb.jt.chat.server.core;
+
+public interface ChatServerListener {
+ void onChatServerMessage(String msg);
+}
diff --git a/Chat/chat-server/src/ru/gb/jt/chat/server/core/ClientThread.java b/Chat/chat-server/src/ru/gb/jt/chat/server/core/ClientThread.java
new file mode 100644
index 0000000..596c6ef
--- /dev/null
+++ b/Chat/chat-server/src/ru/gb/jt/chat/server/core/ClientThread.java
@@ -0,0 +1,53 @@
+package ru.gb.jt.chat.server.core;
+
+import ru.gb.jt.chat.library.Library;
+import ru.gb.jt.network.SocketThread;
+import ru.gb.jt.network.SocketThreadListener;
+
+import java.net.Socket;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class ClientThread extends SocketThread {
+ private String nickname;
+ private boolean isAuthorized;
+ private boolean isReconnected;
+
+ public ClientThread(SocketThreadListener listener,String name, Socket socket) {
+ super(listener,name, socket);
+ }
+
+ public String getNickname() {
+ return nickname;
+ }
+
+ public boolean isAuthorized() {
+ return isAuthorized;
+ }
+
+ public boolean isReconnected() {
+ return isReconnected;
+ }
+
+ void reconnect() {
+ isReconnected = true;
+ close();
+ }
+
+ void authAccept(String nickname) {
+ isAuthorized = true;
+ this.nickname = nickname;
+ sendMessage(Library.getAuthAccept(nickname));
+ }
+
+ void authFail() {
+ sendMessage(Library.getAuthDenied());
+ close();
+ }
+
+ void msgFormatError(String msg) {
+ sendMessage(Library.getMsgFormatError(msg));
+ close();
+ }
+
+}
diff --git a/Chat/chat-server/src/ru/gb/jt/chat/server/core/SqlClient.java b/Chat/chat-server/src/ru/gb/jt/chat/server/core/SqlClient.java
new file mode 100644
index 0000000..601d0ce
--- /dev/null
+++ b/Chat/chat-server/src/ru/gb/jt/chat/server/core/SqlClient.java
@@ -0,0 +1,38 @@
+package ru.gb.jt.chat.server.core;
+
+import java.sql.*;
+
+public class SqlClient {
+
+ private static Connection connection;
+ private static Statement statement;
+
+ synchronized static void connect() {
+ try {
+ Class.forName("org.sqlite.JDBC");
+ connection = DriverManager.getConnection("jdbc:sqlite:chat-server/chat-server.db");
+ statement = connection.createStatement();
+ } catch (ClassNotFoundException | SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ synchronized static void disconnect() {
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ synchronized static String getNickname(String login, String password) {
+ String query = String.format("select nickname from clients where login='%s' and password='%s'", login, password);
+ try (ResultSet set = statement.executeQuery(query)) {
+ if (set.next())
+ return set.getString(1);
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ return null;
+ }
+}
diff --git a/Chat/chat-server/src/ru/gb/jt/chat/server/gui/ServerGUI.java b/Chat/chat-server/src/ru/gb/jt/chat/server/gui/ServerGUI.java
new file mode 100644
index 0000000..9ffa0f3
--- /dev/null
+++ b/Chat/chat-server/src/ru/gb/jt/chat/server/gui/ServerGUI.java
@@ -0,0 +1,88 @@
+package ru.gb.jt.chat.server.gui;
+
+import ru.gb.jt.chat.server.core.ChatServer;
+import ru.gb.jt.chat.server.core.ChatServerListener;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class ServerGUI extends JFrame implements ActionListener, Thread.UncaughtExceptionHandler, ChatServerListener {
+ private static final int POS_X = 800;
+ private static final int POS_Y = 200;
+ private static final int WIDTH = 600;
+ private static final int HEIGHT = 300;
+
+ private final ChatServer chatServer = new ChatServer(this);
+ private final JButton btnStart = new JButton("Start");
+ private final JButton btnStop = new JButton("Stop");
+ private final JPanel panelTop = new JPanel(new GridLayout(1, 2));
+ private final JTextArea log = new JTextArea();
+
+ ExecutorService executorService = Executors.newFixedThreadPool(2);
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new ServerGUI();
+ }
+ });
+ }
+
+ private ServerGUI() {
+ Thread.setDefaultUncaughtExceptionHandler(this);
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ setBounds(POS_X, POS_Y, WIDTH, HEIGHT);
+ setResizable(false);
+ setTitle("Chat server");
+ setAlwaysOnTop(true);
+ log.setEditable(false);
+ log.setLineWrap(true);
+ JScrollPane scrollLog = new JScrollPane(log);
+
+ btnStart.addActionListener(this);
+ btnStop.addActionListener(this);
+
+ panelTop.add(btnStart);
+ panelTop.add(btnStop);
+ add(panelTop, BorderLayout.NORTH);
+ add(scrollLog, BorderLayout.CENTER);
+ setVisible(true);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object src = e.getSource();
+ if (src == btnStart)
+ chatServer.start(8189);
+ else if (src == btnStop)
+ chatServer.stop();
+// throw new RuntimeException("Hello from EDT");
+ else
+ throw new RuntimeException("Unknown source: " + src);
+ }
+
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ e.printStackTrace();
+ String msg;
+ StackTraceElement[] ste = e.getStackTrace();
+ msg = "Exception in thread " + t.getName() + " " +
+ e.getClass().getCanonicalName() + ": " +
+ e.getMessage() + "\n\t" + ste[0];
+ JOptionPane.showMessageDialog(null, msg, "Exception", JOptionPane.ERROR_MESSAGE);
+ System.exit(1);
+ }
+
+ @Override
+ public void onChatServerMessage(String msg) {
+ SwingUtilities.invokeLater(() -> {
+ log.append(msg + "\n");
+ log.setCaretPosition(log.getDocument().getLength());
+ });
+ }
+}
diff --git a/Chat/log.txt b/Chat/log.txt
new file mode 100644
index 0000000..f845860
--- /dev/null
+++ b/Chat/log.txt
@@ -0,0 +1,131 @@
+ivan: Привет,мир!
+ivan: asdf
+ivan: asfg
+ivan: sd
+ivan: hsrt
+ivan: h
+ivan: ryj
+ivan: ryj
+ivan: ny
+ivan: jms
+ivan: ytkj
+ivan: dsyk
+ivan: dg
+ivan: lf
+ivan: l
+ivan: fg
+ivan: kd
+ivan: fhj
+ivan: s
+ivan: 99 =(
+ivan: Сотая строка!
+ivan: 101!
+ivan: jd
+ivan: gk
+ivan: fuk
+ivan: fg
+ivan: kfg
+ivan: km
+ivan: fuk
+ivan: dty
+ivan: jnsr
+ivan: th
+ivan: serg
+ivan: setr
+ivan: b
+ivan: asvasvasfv
+ivan: sdfv
+ivan: sdf
+ivan: v
+ivan: dsfv
+ivan: sd
+ivan: fv
+ivan: dsgn
+ivan: df
+ivan: gn
+ivan: dfg
+ivan: ndf
+ivan: gn
+ivan: dfgn
+ivan: dfgb
+ivan: dfg
+ivan: dfg
+ivan: dfg
+ivan: b
+ivan: b
+ivan: dsf
+ivan: s
+ivan: fv
+ivan: trb
+ivan: ery
+ivan: zsfv
+ivan: asfgarge
+ivan: sgh
+ivan: et
+ivan: hw
+ivan: eth
+ivan: wrth
+ivan: wrt
+ivan: h
+ivan: rth
+ivan: wrth
+ivan: wrteh
+ivan: esfgosn'dfg
+ivan: sgdh;oinsudgh
+ivan: dgfh
+ivan: dfgj
+ivan: dfg
+ivan: jdf
+ivan: j
+ivan: dfj
+ivan: dfg
+ivan: h
+ivan: dh
+ivan: bth
+ivan: dt
+ivan: b
+ivan: drtb
+ivan: drtb
+ivan: rtb
+ivan: drtb
+null: u
+null: j
+null: p[p[pp[ppp[p[p[ppppppppppppppppppppppppppppppp
+ivan1: 90
+ivan1: 909
+ivan1: k
+ivan1: k
+ivan1: lk
+ivan1: i987
+ivan1: 97
+ivan1: 987
+ivan1: 97898
+ivan1: 89
+ivan1: 9
+ivan1: o
+ivan1: klm
+ivan1: m
+ivan1: k
+ivan1: jkh
+ivan1: k
+ivan1: 1
+ivan1: h
+ivan1: 1
+ivan1: i
+ivan1: k
+ivan1: l
+ivan1: j
+ivan1: k
+ivan1: j
+ivan1: l
+Sla: Последняя строка
+
+Sla: j
+Sla: klj
+Sla: poipo
+Sla: 9
+Sla: lkh
+Sla: hg
+Sla: 7
+Sla: jhj
+Sla: lkj
diff --git a/Chat/network/network.iml b/Chat/network/network.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/Chat/network/network.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Chat/network/src/ru/gb/jt/network/ServerSocketThread.java b/Chat/network/src/ru/gb/jt/network/ServerSocketThread.java
new file mode 100644
index 0000000..ae3269f
--- /dev/null
+++ b/Chat/network/src/ru/gb/jt/network/ServerSocketThread.java
@@ -0,0 +1,45 @@
+package ru.gb.jt.network;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+import java.util.concurrent.*;
+
+
+public class ServerSocketThread extends Thread {
+ private final int port;
+ private final int timeout;
+ private final ServerSocketThreadListener listener;
+
+ public ServerSocketThread(ServerSocketThreadListener listener, String name, int port, int timeout) {
+ super(name);
+ this.port = port;
+ this.timeout = timeout;
+ this.listener = listener;
+ start();
+ }
+
+
+ public void run() {
+ listener.onServerStart(this);
+ try (ServerSocket server = new ServerSocket(port)) {
+ server.setSoTimeout(timeout);
+ listener.onServerSocketCreated(this, server);
+ while (!isInterrupted()) {
+ Socket socket;
+ try {
+ socket = server.accept();
+ } catch (SocketTimeoutException e) {
+ listener.onServerTimeout(this, server);
+ continue;
+ }
+ listener.onSocketAccepted(this, server, socket);
+ }
+ } catch (IOException e) {
+ listener.onServerException(this, e);
+ } finally {
+ listener.onServerStop(this);
+ }
+ }
+}
diff --git a/Chat/network/src/ru/gb/jt/network/ServerSocketThreadListener.java b/Chat/network/src/ru/gb/jt/network/ServerSocketThreadListener.java
new file mode 100644
index 0000000..9325aaf
--- /dev/null
+++ b/Chat/network/src/ru/gb/jt/network/ServerSocketThreadListener.java
@@ -0,0 +1,14 @@
+package ru.gb.jt.network;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public interface ServerSocketThreadListener {
+ void onServerStart(ServerSocketThread thread);
+ void onServerStop(ServerSocketThread thread);
+ void onServerSocketCreated(ServerSocketThread thread, ServerSocket server);
+ void onServerTimeout(ServerSocketThread thread, ServerSocket server);
+ void onSocketAccepted(ServerSocketThread thread, ServerSocket server, Socket socket);
+ void onServerException(ServerSocketThread thread, Throwable exception);
+}
+
diff --git a/Chat/network/src/ru/gb/jt/network/SocketThread.java b/Chat/network/src/ru/gb/jt/network/SocketThread.java
new file mode 100644
index 0000000..70b3610
--- /dev/null
+++ b/Chat/network/src/ru/gb/jt/network/SocketThread.java
@@ -0,0 +1,64 @@
+package ru.gb.jt.network;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.Socket;
+
+public class SocketThread extends Thread {
+
+ private final Socket socket;
+ private DataOutputStream out;
+ private SocketThreadListener listener;
+
+ public SocketThread(SocketThreadListener listener, String name, Socket socket) {
+ super(name);
+ this.socket = socket;
+ this.listener = listener;
+ start();
+ }
+
+
+
+
+ @Override
+ public void run() {
+ try {
+ listener.onSocketStart(this, socket);
+ DataInputStream in = new DataInputStream(socket.getInputStream());
+ out = new DataOutputStream(socket.getOutputStream());
+ listener.onSocketReady(this, socket);
+ while (!isInterrupted()) {
+ String msg = in.readUTF();
+ listener.onReceiveString(this, socket, msg);
+ }
+ } catch (IOException e) {
+ listener.onSocketException(this, e);
+ } finally {
+ close();
+ listener.onSocketStop(this);
+ }
+ }
+
+ public synchronized boolean sendMessage(String msg) {
+ try {
+ out.writeUTF(msg);
+ out.flush();
+ return true;
+ } catch (IOException e) {
+ listener.onSocketException(this, e);
+ close();
+ return false;
+ }
+ }
+
+
+ public synchronized void close() {
+ interrupt();
+ try {
+ socket.close();
+ } catch (IOException e) {
+ listener.onSocketException(this, e);
+ }
+ }
+}
diff --git a/Chat/network/src/ru/gb/jt/network/SocketThreadListener.java b/Chat/network/src/ru/gb/jt/network/SocketThreadListener.java
new file mode 100644
index 0000000..061e9db
--- /dev/null
+++ b/Chat/network/src/ru/gb/jt/network/SocketThreadListener.java
@@ -0,0 +1,12 @@
+package ru.gb.jt.network;
+
+import java.net.Socket;
+
+public interface SocketThreadListener {
+ void onSocketStart(SocketThread thread, Socket socket);
+ void onSocketStop(SocketThread thread);
+ void onSocketReady(SocketThread thread, Socket socket);
+ void onReceiveString(SocketThread thread, Socket socket, String msg);
+ void onSocketException(SocketThread thread, Exception exception);
+}
+
diff --git a/Chat/out/artifacts/.DS_Store b/Chat/out/artifacts/.DS_Store
new file mode 100644
index 0000000..dfcf57d
Binary files /dev/null and b/Chat/out/artifacts/.DS_Store differ
diff --git a/Chat/out/artifacts/J2_Stream200303_jar/J2_Stream200303.jar b/Chat/out/artifacts/J2_Stream200303_jar/J2_Stream200303.jar
new file mode 100644
index 0000000..a2de072
Binary files /dev/null and b/Chat/out/artifacts/J2_Stream200303_jar/J2_Stream200303.jar differ
diff --git a/Chat/out/production/J2_Stream200303/META-INF/J2_Stream200303.kotlin_module b/Chat/out/production/J2_Stream200303/META-INF/J2_Stream200303.kotlin_module
new file mode 100644
index 0000000..a49347a
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/META-INF/J2_Stream200303.kotlin_module differ
diff --git a/Chat/out/production/J2_Stream200303/META-INF/MANIFEST.MF b/Chat/out/production/J2_Stream200303/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..7403a1f
--- /dev/null
+++ b/Chat/out/production/J2_Stream200303/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ru.gb.jtwo.ld.online.server.gui.ServerGUI
+
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/Main.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/Main.class
new file mode 100644
index 0000000..6f935b0
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/Main.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/MyClass.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/MyClass.class
new file mode 100644
index 0000000..b4128a4
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/MyClass.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Background.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Background.class
new file mode 100644
index 0000000..528dddf
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Background.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Ball.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Ball.class
new file mode 100644
index 0000000..fdedeea
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Ball.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/GameObject.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/GameObject.class
new file mode 100644
index 0000000..22286ff
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/GameObject.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCanvas.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCanvas.class
new file mode 100644
index 0000000..334a576
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCanvas.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$1.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$1.class
new file mode 100644
index 0000000..af861b2
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$1.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$2.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$2.class
new file mode 100644
index 0000000..4e67a04
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$2.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles.class
new file mode 100644
index 0000000..b8a2184
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Sprite.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Sprite.class
new file mode 100644
index 0000000..138bdd9
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Sprite.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$ColumnMismatchException.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$ColumnMismatchException.class
new file mode 100644
index 0000000..b2392a4
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$ColumnMismatchException.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$NumberIsNotNumberException.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$NumberIsNotNumberException.class
new file mode 100644
index 0000000..70fd62f
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$NumberIsNotNumberException.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$RowMismatchException.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$RowMismatchException.class
new file mode 100644
index 0000000..c6ee7fb
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$RowMismatchException.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional.class
new file mode 100644
index 0000000..b96254c
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Animal.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Animal.class
new file mode 100644
index 0000000..e09cbec
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Animal.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Bull.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Bull.class
new file mode 100644
index 0000000..34333bc
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Bull.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Human.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Human.class
new file mode 100644
index 0000000..1e76163
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Human.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1.class
new file mode 100644
index 0000000..41fe1e5
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1MyClass.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1MyClass.class
new file mode 100644
index 0000000..7ccca6f
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1MyClass.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Booyan.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Booyan.class
new file mode 100644
index 0000000..44a5c1e
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Booyan.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Creature.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Creature.class
new file mode 100644
index 0000000..b8a2902
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Creature.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$IOStream.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$IOStream.class
new file mode 100644
index 0000000..9b13ea4
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$IOStream.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$KeyboardListener.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$KeyboardListener.class
new file mode 100644
index 0000000..740579b
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$KeyboardListener.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Minotaur.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Minotaur.class
new file mode 100644
index 0000000..3964cc8
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Minotaur.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main.class
new file mode 100644
index 0000000..44f044c
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/Brick.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/Brick.class
new file mode 100644
index 0000000..6275bfa
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/Brick.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$1.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$1.class
new file mode 100644
index 0000000..24ff548
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$1.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$2.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$2.class
new file mode 100644
index 0000000..8df5088
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$2.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks.class
new file mode 100644
index 0000000..4217f54
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Background.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Background.class
new file mode 100644
index 0000000..04be57a
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Background.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Ball.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Ball.class
new file mode 100644
index 0000000..daad877
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Ball.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$1.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$1.class
new file mode 100644
index 0000000..b7d984b
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$1.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$2.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$2.class
new file mode 100644
index 0000000..fd98894
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$2.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles.class
new file mode 100644
index 0000000..cfa4e35
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/CanvasListener.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/CanvasListener.class
new file mode 100644
index 0000000..7656d51
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/CanvasListener.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/GameObject.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/GameObject.class
new file mode 100644
index 0000000..846d55f
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/GameObject.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/MainCanvas.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/MainCanvas.class
new file mode 100644
index 0000000..4249a7a
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/MainCanvas.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/Sprite.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/Sprite.class
new file mode 100644
index 0000000..71ebe9d
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/Sprite.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/CollectionsHome.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/CollectionsHome.class
new file mode 100644
index 0000000..0a63047
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/CollectionsHome.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Person.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Person.class
new file mode 100644
index 0000000..de6623b
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Person.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Phonebook.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Phonebook.class
new file mode 100644
index 0000000..ff4d994
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Phonebook.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/Box.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/Box.class
new file mode 100644
index 0000000..a17bcab
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/Box.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/MainCollections.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/MainCollections.class
new file mode 100644
index 0000000..f5cd063
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/MainCollections.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$1.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$1.class
new file mode 100644
index 0000000..5ae7ac4
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$1.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$2.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$2.class
new file mode 100644
index 0000000..e6c2cff
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$2.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI.class
new file mode 100644
index 0000000..fb7dfb1
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/core/ChatServer.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/core/ChatServer.class
new file mode 100644
index 0000000..46be6cb
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/core/ChatServer.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI$1.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI$1.class
new file mode 100644
index 0000000..1838348
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI$1.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI.class
new file mode 100644
index 0000000..f861244
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/home/CalcThread.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/home/CalcThread.class
new file mode 100644
index 0000000..c88158c
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/home/CalcThread.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/home/Main.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/home/Main.class
new file mode 100644
index 0000000..40f74e0
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/home/Main.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/online/Main.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/online/Main.class
new file mode 100644
index 0000000..a117ed2
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/online/Main.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/online/MyThread.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/online/MyThread.class
new file mode 100644
index 0000000..7560452
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/online/MyThread.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/online/network/ServerSocketThread.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/online/network/ServerSocketThread.class
new file mode 100644
index 0000000..ba9da3e
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/le/online/network/ServerSocketThread.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/EchoServer.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/EchoServer.class
new file mode 100644
index 0000000..4af6742
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/EchoServer.class differ
diff --git a/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/SimpleClient.class b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/SimpleClient.class
new file mode 100644
index 0000000..5fa0b42
Binary files /dev/null and b/Chat/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/SimpleClient.class differ
diff --git a/Chat/out/production/chat-client/META-INF/chat-client.kotlin_module b/Chat/out/production/chat-client/META-INF/chat-client.kotlin_module
new file mode 100644
index 0000000..a49347a
Binary files /dev/null and b/Chat/out/production/chat-client/META-INF/chat-client.kotlin_module differ
diff --git a/Chat/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$1.class b/Chat/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$1.class
new file mode 100644
index 0000000..ca8bcc8
Binary files /dev/null and b/Chat/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$1.class differ
diff --git a/Chat/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$2.class b/Chat/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$2.class
new file mode 100644
index 0000000..cbd51f3
Binary files /dev/null and b/Chat/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$2.class differ
diff --git a/Chat/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI.class b/Chat/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI.class
new file mode 100644
index 0000000..5c47c71
Binary files /dev/null and b/Chat/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI.class differ
diff --git a/Chat/out/production/chat-library/ru/gb/jt/chat/library/Library.class b/Chat/out/production/chat-library/ru/gb/jt/chat/library/Library.class
new file mode 100644
index 0000000..0b06e1d
Binary files /dev/null and b/Chat/out/production/chat-library/ru/gb/jt/chat/library/Library.class differ
diff --git a/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServer.class b/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServer.class
new file mode 100644
index 0000000..ee03ecb
Binary files /dev/null and b/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServer.class differ
diff --git a/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServerListener.class b/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServerListener.class
new file mode 100644
index 0000000..e269f74
Binary files /dev/null and b/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServerListener.class differ
diff --git a/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/ClientThread.class b/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/ClientThread.class
new file mode 100644
index 0000000..82bfed3
Binary files /dev/null and b/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/ClientThread.class differ
diff --git a/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/SqlClient.class b/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/SqlClient.class
new file mode 100644
index 0000000..af3ea86
Binary files /dev/null and b/Chat/out/production/chat-server/ru/gb/jt/chat/server/core/SqlClient.class differ
diff --git a/Chat/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI$1.class b/Chat/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI$1.class
new file mode 100644
index 0000000..308a7f2
Binary files /dev/null and b/Chat/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI$1.class differ
diff --git a/Chat/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI.class b/Chat/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI.class
new file mode 100644
index 0000000..d2c1040
Binary files /dev/null and b/Chat/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI.class differ
diff --git a/Chat/out/production/network/ru/gb/jt/network/ServerSocketThread.class b/Chat/out/production/network/ru/gb/jt/network/ServerSocketThread.class
new file mode 100644
index 0000000..941260e
Binary files /dev/null and b/Chat/out/production/network/ru/gb/jt/network/ServerSocketThread.class differ
diff --git a/Chat/out/production/network/ru/gb/jt/network/ServerSocketThreadListener.class b/Chat/out/production/network/ru/gb/jt/network/ServerSocketThreadListener.class
new file mode 100644
index 0000000..4fe323a
Binary files /dev/null and b/Chat/out/production/network/ru/gb/jt/network/ServerSocketThreadListener.class differ
diff --git a/Chat/out/production/network/ru/gb/jt/network/SocketThread.class b/Chat/out/production/network/ru/gb/jt/network/SocketThread.class
new file mode 100644
index 0000000..cb83071
Binary files /dev/null and b/Chat/out/production/network/ru/gb/jt/network/SocketThread.class differ
diff --git a/Chat/out/production/network/ru/gb/jt/network/SocketThreadListener.class b/Chat/out/production/network/ru/gb/jt/network/SocketThreadListener.class
new file mode 100644
index 0000000..34bcf34
Binary files /dev/null and b/Chat/out/production/network/ru/gb/jt/network/SocketThreadListener.class differ
diff --git a/Chat/src/Geekbrains/Main.java b/Chat/src/Geekbrains/Main.java
new file mode 100644
index 0000000..048132b
--- /dev/null
+++ b/Chat/src/Geekbrains/Main.java
@@ -0,0 +1,96 @@
+package Geekbrains;
+
+public class Main {
+
+ public static void main(String[] args) {
+ // write your code here
+ }
+
+ public static class WaitNotifyClass {
+ private final Object mon = new Object();
+ private volatile char currentLetter = 'A';
+
+ public static void main(String[] args) {
+ WaitNotifyClass w = new WaitNotifyClass();
+
+ Thread t1 = new Thread(() -> {
+ w.printA();
+ });
+
+ Thread t2 = new Thread(() -> {
+ w.printB();
+ });
+
+ // Новый поток для метода .printC()
+ Thread t3 = new Thread(() -> {
+ w.printC();
+ });
+
+ t1.start();
+ t2.start();
+ t3.start();
+
+ }
+
+ public void printA(){
+ synchronized (mon){
+ try {
+ for (int i = 0; i < 5; i++) {
+ while (currentLetter != 'A'){
+ mon.wait();
+ }
+ System.out.print("A");
+ currentLetter = 'B';
+ // all тк потоков больше чем 2
+ mon.notifyAll();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ public void printB() {
+ synchronized (mon) {
+ try {
+ for (int i = 0; i < 5; i++) {
+ while (currentLetter != 'B') {
+ mon.wait();
+ }
+ System.out.print("B");
+ currentLetter = 'C';
+ // all тк потоков больше чем 2
+ mon.notifyAll();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+ public void printC() {
+ // Синхпрнизация по монитору
+ synchronized (mon) {
+ try {
+
+ for (int i = 0; i < 5; i++) {
+
+ while (currentLetter != 'C') {
+ mon.wait();
+ }
+ System.out.print("C");
+ currentLetter = 'A';
+ // all тк потоков больще чем 2
+ mon.notifyAll();
+ }
+
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+ }
+
+}
diff --git a/ThreadTest/ThreadTest.iml b/ThreadTest/ThreadTest.iml
new file mode 100644
index 0000000..d5c0743
--- /dev/null
+++ b/ThreadTest/ThreadTest.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/generic/generic.iml b/generic/generic.iml
new file mode 100644
index 0000000..d5c0743
--- /dev/null
+++ b/generic/generic.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testgeneric/testgeneric.iml b/testgeneric/testgeneric.iml
new file mode 100644
index 0000000..d5c0743
--- /dev/null
+++ b/testgeneric/testgeneric.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/untitled9/.DS_Store b/untitled9/.DS_Store
new file mode 100644
index 0000000..9a874b5
Binary files /dev/null and b/untitled9/.DS_Store differ
diff --git a/untitled9/.idea/.gitignore b/untitled9/.idea/.gitignore
new file mode 100644
index 0000000..5c98b42
--- /dev/null
+++ b/untitled9/.idea/.gitignore
@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml
\ No newline at end of file
diff --git a/untitled9/.idea/encodings.xml b/untitled9/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/untitled9/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/.idea/misc.xml b/untitled9/.idea/misc.xml
new file mode 100644
index 0000000..5217e29
--- /dev/null
+++ b/untitled9/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/.idea/modules.xml b/untitled9/.idea/modules.xml
new file mode 100644
index 0000000..deff887
--- /dev/null
+++ b/untitled9/.idea/modules.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/.idea/uiDesigner.xml b/untitled9/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/untitled9/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/.idea/vcs.xml b/untitled9/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/untitled9/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/J2_Stream200303.iml b/untitled9/J2_Stream200303.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/untitled9/J2_Stream200303.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/chat-client/chat-client.iml b/untitled9/chat-client/chat-client.iml
new file mode 100644
index 0000000..4ba0082
--- /dev/null
+++ b/untitled9/chat-client/chat-client.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/chat-client/src/ru/gb/jt/chat/client/ClientGUI.java b/untitled9/chat-client/src/ru/gb/jt/chat/client/ClientGUI.java
new file mode 100644
index 0000000..23d37e6
--- /dev/null
+++ b/untitled9/chat-client/src/ru/gb/jt/chat/client/ClientGUI.java
@@ -0,0 +1,201 @@
+package ru.gb.jt.chat.client;
+
+import ru.gb.jt.chat.library.Library;
+import ru.gb.jt.network.SocketThread;
+import ru.gb.jt.network.SocketThreadListener;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.Socket;
+
+public class ClientGUI extends JFrame implements ActionListener, Thread.UncaughtExceptionHandler, SocketThreadListener {
+
+ private static final int WIDTH = 400;
+ private static final int HEIGHT = 300;
+
+ private final JTextArea log = new JTextArea();
+ private final JPanel panelTop = new JPanel(new GridLayout(2, 3));
+ private final JTextField tfIPAddress = new JTextField("127.0.0.1");
+ private final JTextField tfPort = new JTextField("8190");
+ private final JCheckBox cbAlwaysOnTop = new JCheckBox("Always on top");
+ private final JTextField tfLogin = new JTextField("ivan");
+ private final JPasswordField tfPassword = new JPasswordField("123");
+ private final JButton btnLogin = new JButton("Login");
+
+ private final JPanel panelBottom = new JPanel(new BorderLayout());
+ private final JButton btnDisconnect = new JButton("Disconnect");
+ private final JTextField tfMessage = new JTextField();
+ private final JButton btnSend = new JButton("Send");
+
+ private final JList userList = new JList<>();
+ private SocketThread socketThread;
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new ClientGUI();
+ }
+ });
+ }
+
+ private ClientGUI() {
+ Thread.setDefaultUncaughtExceptionHandler(this);
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ setLocationRelativeTo(null);
+ setSize(WIDTH, HEIGHT);
+ setTitle("Chat client");
+ String[] users = {"user1", "user2", "user3", "user4", "user5",
+ "user_with_an_exceptionally_long_name_in_this_chat"};
+ userList.setListData(users);
+ log.setEditable(false);
+ JScrollPane scrollLog = new JScrollPane(log);
+ JScrollPane scrollUsers = new JScrollPane(userList);
+ scrollUsers.setPreferredSize(new Dimension(100, 0));
+ cbAlwaysOnTop.addActionListener(this);
+ btnSend.addActionListener(this);
+ tfMessage.addActionListener(this);
+ btnLogin.addActionListener(this);
+
+ panelTop.add(tfIPAddress);
+ panelTop.add(tfPort);
+ panelTop.add(cbAlwaysOnTop);
+ panelTop.add(tfLogin);
+ panelTop.add(tfPassword);
+ panelTop.add(btnLogin);
+ panelBottom.add(btnDisconnect, BorderLayout.WEST);
+ panelBottom.add(tfMessage, BorderLayout.CENTER);
+ panelBottom.add(btnSend, BorderLayout.EAST);
+ panelBottom.setVisible(false);
+
+ add(scrollLog, BorderLayout.CENTER);
+ add(scrollUsers, BorderLayout.EAST);
+ add(panelTop, BorderLayout.NORTH);
+ add(panelBottom, BorderLayout.SOUTH);
+
+ setVisible(true);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object src = e.getSource();
+ if (src == cbAlwaysOnTop) {
+ setAlwaysOnTop(cbAlwaysOnTop.isSelected());
+ } else if (src == btnSend || src == tfMessage) {
+ sendMessage();
+ } else if (src == btnLogin) {
+ connect();
+ } else if (src == btnDisconnect) {
+ socketThread.close();
+ }
+ else
+ throw new RuntimeException("Unknown source: " + src);
+ }
+
+ private void connect() {
+ try {
+ Socket socket = new Socket(tfIPAddress.getText(), Integer.parseInt(tfPort.getText()));
+ socketThread = new SocketThread(this, "Client", socket);
+ } catch (IOException e) {
+ showException(Thread.currentThread(), e);
+ }
+ }
+
+ private void sendMessage() {
+ String msg = tfMessage.getText();
+ if ("".equals(msg)) return;
+ tfMessage.setText(null);
+ tfMessage.grabFocus();
+ socketThread.sendMessage(msg);
+
+ if (!"".equals(msg)) {
+ tfMessage.setText(null);
+ tfMessage.grabFocus();
+ socketThread.sendMessage(msg);
+ }
+
+// putLog(String.format("%s: %s", username, msg));
+// wrtMsgToLogFile(msg, username);
+ }
+
+ private void wrtMsgToLogFile(String msg, String username) {
+ try (FileWriter out = new FileWriter("log.txt", true)) {
+ out.write(username + ": " + msg + "\n");
+ out.flush();
+ } catch (IOException e) {
+ showException(Thread.currentThread(), e);
+ }
+ }
+
+ private void putLog(String msg) {
+ if ("".equals(msg)) return;
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ log.append(msg + "\n");
+ log.setCaretPosition(log.getDocument().getLength());
+ }
+ });
+ }
+
+ private void showException(Thread t, Throwable e) {
+ String msg;
+ StackTraceElement[] ste = e.getStackTrace();
+ if (ste.length == 0)
+ msg = "Empty Stacktrace";
+ else {
+ msg = "Exception in " + t.getName() + " " +
+ e.getClass().getCanonicalName() + ": " +
+ e.getMessage() + "\n\t at " + ste[0];
+ }
+ JOptionPane.showMessageDialog(null, msg, "Exception", JOptionPane.ERROR_MESSAGE);
+ }
+
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ e.printStackTrace();
+ showException(t, e);
+ System.exit(1);
+ }
+
+ /**
+ * Socket thread methods
+ * */
+
+ @Override
+ public void onSocketStart(SocketThread thread, Socket socket) {
+ putLog("Start");
+ }
+
+ @Override
+ public void onSocketStop(SocketThread thread) {
+ putLog("Stop");
+ panelBottom.setVisible(false);
+ panelTop.setVisible(true);
+ }
+
+ @Override
+ public void onSocketReady(SocketThread thread, Socket socket) {
+ putLog("Ready");
+ panelBottom.setVisible(true);
+ panelTop.setVisible(false);
+ String login = tfLogin.getText();
+ String password = new String(tfPassword.getPassword());
+ thread.sendMessage(Library.getAuthRequest(login, password));
+
+ }
+
+ @Override
+ public void onReceiveString(SocketThread thread, Socket socket, String msg) {
+ putLog(msg);
+ }
+
+ @Override
+ public void onSocketException(SocketThread thread, Exception exception) {
+ showException(thread, exception);
+ }
+}
diff --git a/untitled9/chat-library/chat-library.iml b/untitled9/chat-library/chat-library.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/untitled9/chat-library/chat-library.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/chat-library/src/ru/gb/jt/chat/library/Library.java b/untitled9/chat-library/src/ru/gb/jt/chat/library/Library.java
new file mode 100644
index 0000000..fd53f63
--- /dev/null
+++ b/untitled9/chat-library/src/ru/gb/jt/chat/library/Library.java
@@ -0,0 +1,41 @@
+package ru.gb.jt.chat.library;
+
+public class Library {
+ /*
+/auth_request±login±password
+/auth_accept±nickname
+/auth_error
+/broadcast±msg
+/msg_format_error±msg
+* */
+ public static final String DELIMITER = "±";
+ public static final String AUTH_REQUEST = "/auth_request";
+ public static final String AUTH_ACCEPT = "/auth_accept";
+ public static final String AUTH_DENIED = "/auth_denied";
+ public static final String MSG_FORMAT_ERROR = "/msg_format_error";
+ // если мы вдруг не поняли, что за сообщение и не смогли разобрать
+ public static final String TYPE_BROADCAST = "/bcast";
+ // то есть сообщение, которое будет посылаться всем
+
+ public static String getAuthRequest(String login, String password) {
+ return AUTH_REQUEST + DELIMITER + login + DELIMITER + password;
+ }
+
+ public static String getAuthAccept(String nickname) {
+ return AUTH_ACCEPT + DELIMITER + nickname;
+ }
+
+ public static String getAuthDenied() {
+ return AUTH_DENIED;
+ }
+
+ public static String getMsgFormatError(String message) {
+ return MSG_FORMAT_ERROR + DELIMITER + message;
+ }
+
+ public static String getTypeBroadcast(String src, String message) {
+ return TYPE_BROADCAST + DELIMITER + System.currentTimeMillis() +
+ DELIMITER + src + DELIMITER + message;
+ }
+
+}
diff --git a/untitled9/chat-server/chat-server.db b/untitled9/chat-server/chat-server.db
new file mode 100644
index 0000000..ecbff3e
Binary files /dev/null and b/untitled9/chat-server/chat-server.db differ
diff --git a/untitled9/chat-server/chat-server.iml b/untitled9/chat-server/chat-server.iml
new file mode 100644
index 0000000..f370ad6
--- /dev/null
+++ b/untitled9/chat-server/chat-server.iml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/chat-server/sqlite-jdbc-3.21.0.jar b/untitled9/chat-server/sqlite-jdbc-3.21.0.jar
new file mode 100644
index 0000000..56b627d
Binary files /dev/null and b/untitled9/chat-server/sqlite-jdbc-3.21.0.jar differ
diff --git a/untitled9/chat-server/src/ru/gb/jt/chat/server/core/ChatServer.java b/untitled9/chat-server/src/ru/gb/jt/chat/server/core/ChatServer.java
new file mode 100644
index 0000000..60edd63
--- /dev/null
+++ b/untitled9/chat-server/src/ru/gb/jt/chat/server/core/ChatServer.java
@@ -0,0 +1,146 @@
+package ru.gb.jt.chat.server.core;
+
+import ru.gb.jt.chat.library.Library;
+import ru.gb.jt.network.ServerSocketThread;
+import ru.gb.jt.network.ServerSocketThreadListener;
+import ru.gb.jt.network.SocketThread;
+import ru.gb.jt.network.SocketThreadListener;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Vector;
+
+public class ChatServer implements ServerSocketThreadListener, SocketThreadListener {
+
+ ServerSocketThread server;
+ ChatServerListener listener;
+ private Vector clients = new Vector<>();
+
+ public ChatServer(ChatServerListener listener) {
+ this.listener = listener;
+ }
+
+ public void start(int port) {
+ if (server == null || !server.isAlive()) {
+ server = new ServerSocketThread(this, "Server", port, 2000);
+ } else {
+ putLog("Server already started!");
+ }
+ }
+
+ public void stop() {
+ if (server != null && server.isAlive()) {
+ server.interrupt(); //null.interrupt();
+ } else {
+ putLog("Server is not running");
+ }
+ }
+
+ private void putLog(String msg) {
+ listener.onChatServerMessage(msg);
+ }
+
+ /**
+ * Server Socket Thread methods
+ * */
+
+ @Override
+ public void onServerStart(ServerSocketThread thread) {
+ putLog("Server started");
+ SqlClient.connect();
+ }
+
+ @Override
+ public void onServerStop(ServerSocketThread thread) {
+ putLog("Server stopped");
+ SqlClient.disconnect();
+ }
+
+ @Override
+ public void onServerSocketCreated(ServerSocketThread thread, ServerSocket server) {
+ putLog("Server socket created");
+ }
+
+ @Override
+ public void onServerTimeout(ServerSocketThread thread, ServerSocket server) { }
+
+ @Override
+ public void onSocketAccepted(ServerSocketThread thread, ServerSocket server, Socket socket) {
+ putLog("Client connected");
+ String name = "Socket Thread " + socket.getInetAddress() + ":" + socket.getPort();
+ new ClientThread(this, name, socket);
+ }
+
+ @Override
+ public void onServerException(ServerSocketThread thread, Throwable exception) {
+ exception.printStackTrace();
+ }
+
+ /**
+ * Socket Thread methods
+ * */
+
+ @Override
+ public void onSocketStart(SocketThread thread, Socket socket) {
+ putLog("Client connected");
+ }
+
+ @Override
+ public void onSocketStop(SocketThread thread) {
+ putLog("Client disconnected");
+ clients.remove(thread);
+ }
+
+ @Override
+ public void onSocketReady(SocketThread thread, Socket socket) {
+ putLog("Client is ready to chat");
+ clients.add(thread);
+ }
+
+ @Override
+ public void onReceiveString(SocketThread thread, Socket socket, String msg) {
+ ClientThread client = (ClientThread) thread;
+ if (client.isAuthorized()) {
+ handleAutorizedMessage(client, msg);
+ } else {
+ handleNonAuthorizedMessage(client, msg);
+ }
+ }
+
+ @Override
+ public void onSocketException(SocketThread thread, Exception exception) {
+ exception.printStackTrace();
+ }
+
+ private void handleNonAuthorizedMessage(ClientThread client, String msg) {
+// /auth_request±login±password
+ String[] arr = msg.split(Library.DELIMITER);
+ if (arr.length != 3 || !arr[0].equals(Library.AUTH_REQUEST)) {
+ client.msgFormatError(msg);
+ return;
+ }
+ String login = arr[1];
+ String password = arr[2];
+ String nickname = SqlClient.getNickname(login, password);
+ if (nickname == null) {
+ putLog("Invalid credentials for user" + login);
+ client.authFail();
+ return;
+ }
+ client.authAccept(nickname);
+ sendToAllAuthorizedClients(Library.getTypeBroadcast("Server", nickname + " connected"));
+
+ }
+
+ private void handleAutorizedMessage(ClientThread client, String msg) {
+ sendToAllAuthorizedClients(msg);
+ }
+
+ private void sendToAllAuthorizedClients(String msg) {
+ for (int i = 0; i < clients.size(); i++) {
+ ClientThread client = (ClientThread) clients.get(i);
+ if (!client.isAuthorized()) continue;
+ client.sendMessage(msg);
+ }
+ }
+}
diff --git a/untitled9/chat-server/src/ru/gb/jt/chat/server/core/ChatServerListener.java b/untitled9/chat-server/src/ru/gb/jt/chat/server/core/ChatServerListener.java
new file mode 100644
index 0000000..d7c35bc
--- /dev/null
+++ b/untitled9/chat-server/src/ru/gb/jt/chat/server/core/ChatServerListener.java
@@ -0,0 +1,5 @@
+package ru.gb.jt.chat.server.core;
+
+public interface ChatServerListener {
+ void onChatServerMessage(String msg);
+}
diff --git a/untitled9/chat-server/src/ru/gb/jt/chat/server/core/ClientThread.java b/untitled9/chat-server/src/ru/gb/jt/chat/server/core/ClientThread.java
new file mode 100644
index 0000000..a77f560
--- /dev/null
+++ b/untitled9/chat-server/src/ru/gb/jt/chat/server/core/ClientThread.java
@@ -0,0 +1,41 @@
+package ru.gb.jt.chat.server.core;
+
+import ru.gb.jt.chat.library.Library;
+import ru.gb.jt.network.SocketThread;
+import ru.gb.jt.network.SocketThreadListener;
+
+import java.net.Socket;
+
+public class ClientThread extends SocketThread {
+ private String nickname;
+ private boolean isAuthorized;
+
+ public ClientThread(SocketThreadListener listener, String name, Socket socket) {
+ super(listener, name, socket);
+ }
+
+ public String getNickname() {
+ return nickname;
+ }
+
+ public boolean isAuthorized() {
+ return isAuthorized;
+ }
+
+ void authAccept(String nickname) {
+ isAuthorized = true;
+ this.nickname = nickname;
+ sendMessage(Library.getAuthAccept(nickname));
+ }
+
+ void authFail() {
+ sendMessage(Library.getAuthDenied());
+ close();
+ }
+
+ void msgFormatError(String msg) {
+ sendMessage(Library.getMsgFormatError(msg));
+ close();
+ }
+
+}
diff --git a/untitled9/chat-server/src/ru/gb/jt/chat/server/core/SqlClient.java b/untitled9/chat-server/src/ru/gb/jt/chat/server/core/SqlClient.java
new file mode 100644
index 0000000..601d0ce
--- /dev/null
+++ b/untitled9/chat-server/src/ru/gb/jt/chat/server/core/SqlClient.java
@@ -0,0 +1,38 @@
+package ru.gb.jt.chat.server.core;
+
+import java.sql.*;
+
+public class SqlClient {
+
+ private static Connection connection;
+ private static Statement statement;
+
+ synchronized static void connect() {
+ try {
+ Class.forName("org.sqlite.JDBC");
+ connection = DriverManager.getConnection("jdbc:sqlite:chat-server/chat-server.db");
+ statement = connection.createStatement();
+ } catch (ClassNotFoundException | SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ synchronized static void disconnect() {
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ synchronized static String getNickname(String login, String password) {
+ String query = String.format("select nickname from clients where login='%s' and password='%s'", login, password);
+ try (ResultSet set = statement.executeQuery(query)) {
+ if (set.next())
+ return set.getString(1);
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ return null;
+ }
+}
diff --git a/untitled9/chat-server/src/ru/gb/jt/chat/server/gui/ServerGUI.java b/untitled9/chat-server/src/ru/gb/jt/chat/server/gui/ServerGUI.java
new file mode 100644
index 0000000..28023ad
--- /dev/null
+++ b/untitled9/chat-server/src/ru/gb/jt/chat/server/gui/ServerGUI.java
@@ -0,0 +1,85 @@
+package ru.gb.jt.chat.server.gui;
+
+import ru.gb.jt.chat.server.core.ChatServer;
+import ru.gb.jt.chat.server.core.ChatServerListener;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class ServerGUI extends JFrame implements ActionListener, Thread.UncaughtExceptionHandler, ChatServerListener {
+ private static final int POS_X = 800;
+ private static final int POS_Y = 200;
+ private static final int WIDTH = 600;
+ private static final int HEIGHT = 300;
+
+ private final ChatServer chatServer = new ChatServer(this::onChatServerMessage);
+ private final JButton btnStart = new JButton("Start");
+ private final JButton btnStop = new JButton("Stop");
+ private final JPanel panelTop = new JPanel(new GridLayout(1, 2));
+ private final JTextArea log = new JTextArea();
+
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new ServerGUI();
+ }
+ });
+ }
+
+ private ServerGUI() {
+ Thread.setDefaultUncaughtExceptionHandler(this);
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ setBounds(POS_X, POS_Y, WIDTH, HEIGHT);
+ setResizable(false);
+ setTitle("Chat server");
+ setAlwaysOnTop(true);
+ log.setEditable(false);
+ log.setLineWrap(true);
+ JScrollPane scrollLog = new JScrollPane(log);
+
+ btnStart.addActionListener(this);
+ btnStop.addActionListener(this);
+
+ panelTop.add(btnStart);
+ panelTop.add(btnStop);
+ add(panelTop, BorderLayout.NORTH);
+ add(scrollLog, BorderLayout.CENTER);
+ setVisible(true);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object src = e.getSource();
+ if (src == btnStart)
+ chatServer.start(8190);
+ else if (src == btnStop)
+ chatServer.stop();
+// throw new RuntimeException("Hello from EDT");
+ else
+ throw new RuntimeException("Unknown source: " + src);
+ }
+
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ e.printStackTrace();
+ String msg;
+ StackTraceElement[] ste = e.getStackTrace();
+ msg = "Exception in thread " + t.getName() + " " +
+ e.getClass().getCanonicalName() + ": " +
+ e.getMessage() + "\n\t" + ste[0];
+ JOptionPane.showMessageDialog(null, msg, "Exception", JOptionPane.ERROR_MESSAGE);
+ System.exit(1);
+ }
+
+ @Override
+ public void onChatServerMessage(String msg) {
+ SwingUtilities.invokeLater(() -> {
+ log.append(msg + "\n");
+ log.setCaretPosition(log.getDocument().getLength());
+ });
+ }
+}
diff --git a/untitled9/log.txt b/untitled9/log.txt
new file mode 100644
index 0000000..d042b0c
--- /dev/null
+++ b/untitled9/log.txt
@@ -0,0 +1,90 @@
+ivan: asdfasdf
+ivan: asdf
+ivan: asfg
+ivan: sd
+ivan: hsrt
+ivan: h
+ivan: ryj
+ivan: ryj
+ivan: ny
+ivan: jms
+ivan: ytkj
+ivan: dsyk
+ivan: dg
+ivan: lf
+ivan: l
+ivan: fg
+ivan: kd
+ivan: fhj
+ivan: s
+ivan: hs
+ivan: h
+ivan: sy
+ivan: jd
+ivan: gk
+ivan: fuk
+ivan: fg
+ivan: kfg
+ivan: km
+ivan: fuk
+ivan: dty
+ivan: jnsr
+ivan: th
+ivan: serg
+ivan: setr
+ivan: b
+ivan: asvasvasfv
+ivan: sdfv
+ivan: sdf
+ivan: v
+ivan: dsfv
+ivan: sd
+ivan: fv
+ivan: dsgn
+ivan: df
+ivan: gn
+ivan: dfg
+ivan: ndf
+ivan: gn
+ivan: dfgn
+ivan: dfgb
+ivan: dfg
+ivan: dfg
+ivan: dfg
+ivan: b
+ivan: b
+ivan: dsf
+ivan: s
+ivan: fv
+ivan: trb
+ivan: ery
+ivan: zsfv
+ivan: asfgarge
+ivan: sgh
+ivan: et
+ivan: hw
+ivan: eth
+ivan: wrth
+ivan: wrt
+ivan: h
+ivan: rth
+ivan: wrth
+ivan: wrteh
+ivan: esfgosn'dfg
+ivan: sgdh;oinsudgh
+ivan: dgfh
+ivan: dfgj
+ivan: dfg
+ivan: jdf
+ivan: j
+ivan: dfj
+ivan: dfg
+ivan: h
+ivan: dh
+ivan: bth
+ivan: dt
+ivan: b
+ivan: drtb
+ivan: drtb
+ivan: rtb
+ivan: drtb
diff --git a/untitled9/network/network.iml b/untitled9/network/network.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/untitled9/network/network.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/untitled9/network/src/ru/gb/jt/network/ServerSocketThread.java b/untitled9/network/src/ru/gb/jt/network/ServerSocketThread.java
new file mode 100644
index 0000000..7be047b
--- /dev/null
+++ b/untitled9/network/src/ru/gb/jt/network/ServerSocketThread.java
@@ -0,0 +1,43 @@
+package ru.gb.jt.network;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+
+public class ServerSocketThread extends Thread {
+ private final int port;
+ private final int timeout;
+ private final ServerSocketThreadListener listener;
+
+ public ServerSocketThread(ServerSocketThreadListener listener, String name, int port, int timeout) {
+ super(name);
+ this.port = port;
+ this.timeout = timeout;
+ this.listener = listener;
+ start();
+ }
+
+ @Override
+ public void run() {
+ listener.onServerStart(this);
+ try (ServerSocket server = new ServerSocket(port)) {
+ server.setSoTimeout(timeout);
+ listener.onServerSocketCreated(this, server);
+ while (!isInterrupted()) {
+ Socket socket;
+ try {
+ socket = server.accept();
+ } catch (SocketTimeoutException e) {
+ listener.onServerTimeout(this, server);
+ continue;
+ }
+ listener.onSocketAccepted(this, server, socket);
+ }
+ } catch (IOException e) {
+ listener.onServerException(this, e);
+ } finally {
+ listener.onServerStop(this);
+ }
+ }
+}
diff --git a/untitled9/network/src/ru/gb/jt/network/ServerSocketThreadListener.java b/untitled9/network/src/ru/gb/jt/network/ServerSocketThreadListener.java
new file mode 100644
index 0000000..e5089e0
--- /dev/null
+++ b/untitled9/network/src/ru/gb/jt/network/ServerSocketThreadListener.java
@@ -0,0 +1,13 @@
+package ru.gb.jt.network;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public interface ServerSocketThreadListener {
+ void onServerStart(ServerSocketThread thread);
+ void onServerStop(ServerSocketThread thread);
+ void onServerSocketCreated(ServerSocketThread thread, ServerSocket server);
+ void onServerTimeout(ServerSocketThread thread, ServerSocket server);
+ void onSocketAccepted(ServerSocketThread thread, ServerSocket server, Socket socket);
+ void onServerException(ServerSocketThread thread, Throwable exception);
+}
diff --git a/untitled9/network/src/ru/gb/jt/network/SocketThread.java b/untitled9/network/src/ru/gb/jt/network/SocketThread.java
new file mode 100644
index 0000000..94dbb90
--- /dev/null
+++ b/untitled9/network/src/ru/gb/jt/network/SocketThread.java
@@ -0,0 +1,60 @@
+package ru.gb.jt.network;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.Socket;
+
+public class SocketThread extends Thread {
+
+ private final Socket socket;
+ private DataOutputStream out;
+ private SocketThreadListener listener;
+
+ public SocketThread(SocketThreadListener listener, String name, Socket socket) {
+ super(name);
+ this.socket = socket;
+ this.listener = listener;
+ start();
+ }
+
+ @Override
+ public void run() {
+ try {
+ listener.onSocketStart(this, socket);
+ DataInputStream in = new DataInputStream(socket.getInputStream());
+ out = new DataOutputStream(socket.getOutputStream());
+ listener.onSocketReady(this, socket);
+ while (!isInterrupted()) {
+ String msg = in.readUTF();
+ listener.onReceiveString(this, socket, msg);
+ }
+ } catch (IOException e) {
+ listener.onSocketException(this, e);
+ } finally {
+ close();
+ listener.onSocketStop(this);
+ }
+ }
+
+ public synchronized boolean sendMessage(String msg) {
+ try {
+ out.writeUTF(msg);
+ out.flush();
+ return true;
+ } catch (IOException e) {
+ listener.onSocketException(this, e);
+ close();
+ return false;
+ }
+ }
+
+ public synchronized void close() {
+ interrupt();
+ try {
+ socket.close();
+ } catch (IOException e) {
+ listener.onSocketException(this, e);
+ }
+ }
+}
diff --git a/untitled9/network/src/ru/gb/jt/network/SocketThreadListener.java b/untitled9/network/src/ru/gb/jt/network/SocketThreadListener.java
new file mode 100644
index 0000000..f48cb81
--- /dev/null
+++ b/untitled9/network/src/ru/gb/jt/network/SocketThreadListener.java
@@ -0,0 +1,127 @@
+package ru.gb.jt.network;
+
+import java.net.Socket;
+
+public interface SocketThreadListener {
+ void onSocketStart(SocketThread thread, Socket socket);
+ void onSocketStop(SocketThread thread);
+
+ void onSocketReady(SocketThread thread, Socket socket);
+ void onReceiveString(SocketThread thread, Socket socket, String msg);
+
+ void onSocketException(SocketThread thread, Exception exception);
+}
+
+/*
+почему у сервера только номер порта, а у клиента указан и ip и порт? или ip нужен для того, чтобы сервер понимал кому именно отправить то или иное сообщение(либо от другого клиента,либо какую то рассылку)?
+
+1. В методах интерфейса: в некоторых передаетсятолько поток, а в некоторых и поток и сокет. (Хотя вроде для каждого сокета создается свой поток.) Поэтому вопрос зачем передавать обе переменные. Пока в нашем коде переопределенные методы не используют эти переменные, кроме методов exception.
+2. Когда закрываю онко клиента без disconnect, т.к. без закрытия потока, вываливаетяс SocketException, хотя я его и добавил. Сделал скриншот, тут добавить нет возможности. Отправлю через телегу.
+3.2 вопрос решил добавив в класс ClientGUI интерфейс Closable. Ошибка пропала. Правильно ли сделал или нужно было как-то по другому?
+
+1. При реализации кнопки Disconnect использовал метод socketThread.close(). При его вызове появляется исключение. Бросает его вроде бы клиент, т.к. именно над ним появляется модальное окно с текстом. Но описание ошибки появляется в консоли сервера:
+java.io.EOFException
+at java.base/java.io.DataInputStream.readUnsignedShort(DataInputStream.java:345)
+at java.base/java.io.DataInputStream.readUTF(DataInputStream.java:594)
+at java.base/java.io.DataInputStream.readUTF(DataInputStream.java:569)
+at ru.gb.network.SocketThread.run(SocketThread.java:29)
+В консоли клиента сообщение: "INTERRUPTED while loading Image".
+При первом разрыве соединения окно с ошибкой висит до нажатия кнопки "ОК". При последующих разрывах соединений окно появляется "мельком". Причина в том, что не корректно прерывается обработка входного потока сервера? Что именно происходит?
+2. После остановки сервера эхо сообщений от клиента по-прежнему приходят. Как будто бы сервер работает. При повторной остановке появляется сообщение, что сервер остановлен. Но эхо приходит. Почему поток сервера не останавливается?
+
+
+Когда нам необходимо было слушать действия СерверСокетТреда/СокетТред, мы решили не передавать экземпляр сервера, а передавать экземпляр класса с интерфейсом (что по сути получилось тоже самое).
+Для чего это сделано? Чтобы СерверСокетТред/СокетТред не имел доступ к другим методам класса сервера?
+Данные полученные сокетом можно прочитать только InputStream'ом?
+
+
+При старте сервера создается ServerSocket и socket от сервера, а при нажатии кнопки login в ChatGUI создается сокет со стороны пользователя, после этого они связываются, и сразу же создается новый socket со стороны сервера? Или сервер просто слушает и при попытке подключения клиентом, создается сокет который подключается к ожидающему сокету клиента?
+При установке Timeout, само выполнение Accept() не прерывается? и просто дается промежуток на обработку новых результатов?
+Не очень понял откуда и куда летят сообщения, понятно что из out в in, но где отправная точка? В клиенте GUI? Он доходит до SocketThread и уходит на вход SocketThread сервера? Как понять обработал письмо сервер или нет?
+
+При коннекте клиента видим: Socket Thread /127.0.0.1:64445 ВОПРОС: Почему порт 64445 а не 8189 ?
+Отсылаю сообщение в любом клиенте: вижу эхо в логе только у того клиента, который это сообщение послал. У другого клиента в лог ничего не приходит. Почему? Ведь оба клиента слушают порт сервера и сервер должен всем всё отправить…
+Почему сделали boolean метод public synchronized boolean sendMessage(String msg) в SocketThread и не использовали ни разу возвращаемое значение? На будущее?
+Запускаем ChatClient не подсоединившить к серверу. Пишем сообщение и жмём SEND. Вываливаются исключения NPE. Как лучше их обработать? В методе sendmessage() обернуть socketThread.sendMessage(msg) траем или просто пробросить в методе исключение и обрабатывать вне его?
+
+1.1.Насколько хорошо нужно продумывать архитектуру приложения при разработке (на примере чата)?
+1.2.На какие моменты стоит образать внимание при ее (архитектуры) описаниии (разработке)?
+1.3.Каковы будут последствия, в случае если архитектура не абстрагирована (направлена на решение конкретной задачи) и сложно ли будет внести изменения?
+2.Что произойдет, если сервер попытается запуститься на зарезервированном порте или уже открытом? придется искать любой другой незанятый? и как тогда клиент узнает, что нужно подключиться к другому порту?
+3.Каким образом подключиться к серверу, у которого ip динамический, то есть менятся периодически? или все чаты/мессенджеры пишутся из расчета того, что ip адрес статический?
+4.В случае с методом sendMessage (из урока) понятно, что он должен быть synchronized, чтобы сообщения появлялись в логе по очереди, а не лезли друг на друга, но непонятно чем грозит, то что метод close не будет synchronized? (Вроде бы получается просто прерываем поток и закрываем сокет, какие здесь могут возникнуть проблемы?)
+
+1. Хотелось бы получить логические умозаключения как вы с коллегой дошли на того решения и архитектуры, которое продемонстрировали на 6 уроке. Как рассуждали, от чего отталкивались. Было бы интересно послушать как рождаются такие решения.
+2. Техника слушателей, которая была показана - ServerSocketThreadListener и SocketThreadListener - как ими управлять, останавливать, обрабатывать? Реализовывать методы интерфейса? Подобный поход - это базовый подход к клиент-серверному взаимодействию?
+3. Не совсем понятно, как правильно работать с IN / OUT при закрытии сокета, на каком уровне нужно и нужно ли их закрывать?
+4. Вкратце, есть ли готовые, коробочные варианты подобной реализации, какие то фреймворки / библиотеки?
+
+ClientGui:
+1. строка 46 Thread.setDefaultUncaughtExceptionHandler(this); - что это?
+2. строка 48 setLocationRelativeTo(null); - что это?
+3. строка 110 socketThread.sendMessage(msg); - как работает метод?
+4. строка 135 showException(Thread t, Throwable e) - как работает метод,
+ChatServer:
+1. строка 18 server = new ServerSocketThread(this, "Server", port, 2000); - почему передаем this
+ServerGUI:
+1. строка 59 uncaughtException(Thread t, Throwable e) - как работает метод
+
+1. Что и прикаких обстоятельствах может пойти не так, если убрать flush? Я убрал, запустил, все работает.
+2. Хотел бы вернуться к вопросу о synchronized методах: https://prnt.sc/rles0v. На сервере будет много объектов типа SocketThread, - это я понимаю. Не понимаю, какие могут быть между ними конфликты. Ведь они будут писать каждый в свою копию DataOutputStream out, и метод close() будет вызываться на каждом из этих объектов независимо от других. Все выглядит так, что тут нет разделяемых даных, и зачем тогда синхронизация?
+
+можно ли во время урока еще раз показать, как передается сообщение от момента нажатия на кнопку и до получения ответа от сервера в чате?
+
+Когда я создаю свой новый проект (потом пакеты, классы и т.п.), то все работает как положено,
+но как только открываю сторонний код (например, код с урока), то он после открытия не запускаются,
+RUN выполнить не могу и поэтому приходится постоянно все уроки копировать в свои новосозданные проекты,
+чтобы запустить код на выполнение (возможно, что так и все это делают всегда. Или нет?)
+
+В Server GUI строка: btnStart.addActionListener(this); в роли какого параметра выступает this?
+При попытке остановить сервер сообщение "server stopped" выводится дважды. Почему?
+ClientGUI. Строка if ("".equals(msg)) return; Что она возвращает? (см. далее вопрос 3)
+
+Вопрос по дженерикам, добавил дженерик в Вектор, и все срослось с массивом, добавление нитей и рассылка всем пользователям, но точно как работает, не совсем догоняю
+
+1) Более подробно расскажите как проходит разработка архитектуры приложения до того как начинается писаться код.
+2) Созданы два интерфейса ServerSocketThreadListener и SocketThreadListener. У них одинаковые методы, почему нельзя сделать один общий интерфейс ThreadListener?
+3) Взаимодействие inputStream и outputStream у Socket и ServerSocket не совсем понял. Какая логика их взаимодействия более подробно объясните пожалуйста.
+
+Как server.accept() помещается в отдельный тред? Автоматически?
+Зачем нам ServerSocketThread и SocketThread? Они же универсальные. Почему нельзя обойтись одним классом?
+
+1.Почему мы в конструкторе (например, в SocketThread) параметр name помещаем в super, а остальные в this. Нельзя все в супер запихнуть?
+2. В классе SocketThread метод run: пишем listener.onSocketStart(this, socket), НО listener.onSocketStop(this) - не нужно передавать в стопе, какой именно сокет был остановлен?
+3. Почему метод public synchronized boolean sendMessage именно булевый? Мы можем возвращать тот же msg в случае успеха и ничего не возвращать в случае провала?
+5. Не разобрался, зачем continue в SocketTimeoutException
+
+сейчас, когда мы адресуем сообщение серверу, он нам отвечает через echo, т.е. дает понять, что сообщение получил и может его обрабатывать. Когда мы будем общаться с кем-либо живым посредством чата, получается, что один серверный сокет будет взаимодействовать с двумя клиентами одновременно, являясь для них чем-то вроде мостика?
+
+1) Предполагается, что "ClientGUI.java" может запустить несколько пользователей. Как запустить файл в IDEA несколько раз?
+
+2) При нажатии на кнопку "Login" выполняется:
+
+ private void connect() {
+ try {
+ Socket socket = new Socket(tfIPAddress.getText(), Integer.parseInt(tfPort.getText()));
+ socketThread = new SocketThread(this, "Client", socket);
+ } catch (IOException e) {
+ showException(Thread.currentThread(), e);
+ }
+ }
+ Логин пользователя - название потока. То есть, каждый логин должен быть уникальным?
+
+3) Vector нужно использовать, чтобы передавать логин и текст?
+
+Вопросы скорее по практике применения модулей в реальной жизни: как лучше разбивать проекты на эти модули (по функционалу я понимаю - а если у них функционал пересекается? мы используем повторяющийся код в двух разных модулях или делаем связь в виде ссылок? ) ? Иногда возникали проблемы с запаковкой в jar ( но это было после ИК, сейчас возможно таких проблем не будет) , если будет возможность покажите нюансы которые могут возникать.
+В курсе были вещи которые вы говорили всегда должны быть в голове у разработчика несмотря на отсутствие в ТЗ , нет ли списка таких вещей или таблички?
+Вопросы про мониторы, как определять места для их расстановки при многопоточности? например если мы делим передачу файлов на несколько потоков, как избежать мешанины в передааваемых данных при этом добиться увелечения скорости разбивки файла на передаваемые байты?
+Необходимо ли делать проверку занятости порта перед созданием там сокета? Подобием пинга с запросам ответа в виде буалена?
+Чем обусловлена необходимость в интерфейсах прописывать параметры, которые по факту в обработчике листенера не используются, более того, как правило, они листенером же и создаются и управляются?
+
+И еще, зачем по большому счету нужны такие методы интерфейса как onServerStart(), onServerStop() – они ведь, получается, дублируют события, которые мы сами и инициируем в том потоке, который использует нашу «библиотеку»
+
+1) По серверу - я правильно понимаю, что мы реализовали паттерн синглтон в public void start в ChatServer? Т.е. мы первый раз инициируем создание экземпляра, а дальше проверяет, создан ли он. Если создан, то используем созданый. Верно?
+2) Прошу повторить насчет интерфейсов - они необходимы для того, чтобы обязать нас реолизовывать определенный набор методов? В этом их задача?
+
+каждая строчка кода вроде сама по себе понятна, но вот их взаимодействие не складывается в общую картину.
+* */
diff --git a/untitled9/out/artifacts/.DS_Store b/untitled9/out/artifacts/.DS_Store
new file mode 100644
index 0000000..dfcf57d
Binary files /dev/null and b/untitled9/out/artifacts/.DS_Store differ
diff --git a/untitled9/out/artifacts/J2_Stream200303_jar/J2_Stream200303.jar b/untitled9/out/artifacts/J2_Stream200303_jar/J2_Stream200303.jar
new file mode 100644
index 0000000..a2de072
Binary files /dev/null and b/untitled9/out/artifacts/J2_Stream200303_jar/J2_Stream200303.jar differ
diff --git a/untitled9/out/production/J2_Stream200303/META-INF/J2_Stream200303.kotlin_module b/untitled9/out/production/J2_Stream200303/META-INF/J2_Stream200303.kotlin_module
new file mode 100644
index 0000000..a49347a
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/META-INF/J2_Stream200303.kotlin_module differ
diff --git a/untitled9/out/production/J2_Stream200303/META-INF/MANIFEST.MF b/untitled9/out/production/J2_Stream200303/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..7403a1f
--- /dev/null
+++ b/untitled9/out/production/J2_Stream200303/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ru.gb.jtwo.ld.online.server.gui.ServerGUI
+
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/Main.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/Main.class
new file mode 100644
index 0000000..6f935b0
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/Main.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/MyClass.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/MyClass.class
new file mode 100644
index 0000000..b4128a4
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/MyClass.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Background.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Background.class
new file mode 100644
index 0000000..528dddf
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Background.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Ball.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Ball.class
new file mode 100644
index 0000000..fdedeea
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Ball.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/GameObject.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/GameObject.class
new file mode 100644
index 0000000..22286ff
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/GameObject.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCanvas.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCanvas.class
new file mode 100644
index 0000000..334a576
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCanvas.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$1.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$1.class
new file mode 100644
index 0000000..af861b2
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$1.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$2.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$2.class
new file mode 100644
index 0000000..4e67a04
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles$2.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles.class
new file mode 100644
index 0000000..b8a2184
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/MainCircles.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Sprite.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Sprite.class
new file mode 100644
index 0000000..138bdd9
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/la/online/circles/Sprite.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$ColumnMismatchException.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$ColumnMismatchException.class
new file mode 100644
index 0000000..b2392a4
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$ColumnMismatchException.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$NumberIsNotNumberException.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$NumberIsNotNumberException.class
new file mode 100644
index 0000000..70fd62f
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$NumberIsNotNumberException.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$RowMismatchException.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$RowMismatchException.class
new file mode 100644
index 0000000..c6ee7fb
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional$RowMismatchException.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional.class
new file mode 100644
index 0000000..b96254c
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/home/Exceptional.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Animal.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Animal.class
new file mode 100644
index 0000000..e09cbec
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Animal.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Bull.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Bull.class
new file mode 100644
index 0000000..34333bc
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Bull.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Human.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Human.class
new file mode 100644
index 0000000..1e76163
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Human.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1.class
new file mode 100644
index 0000000..41fe1e5
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1MyClass.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1MyClass.class
new file mode 100644
index 0000000..7ccca6f
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$1MyClass.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Booyan.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Booyan.class
new file mode 100644
index 0000000..44a5c1e
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Booyan.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Creature.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Creature.class
new file mode 100644
index 0000000..b8a2902
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Creature.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$IOStream.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$IOStream.class
new file mode 100644
index 0000000..9b13ea4
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$IOStream.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$KeyboardListener.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$KeyboardListener.class
new file mode 100644
index 0000000..740579b
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$KeyboardListener.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Minotaur.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Minotaur.class
new file mode 100644
index 0000000..3964cc8
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main$Minotaur.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main.class
new file mode 100644
index 0000000..44f044c
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/Main.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/Brick.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/Brick.class
new file mode 100644
index 0000000..6275bfa
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/Brick.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$1.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$1.class
new file mode 100644
index 0000000..24ff548
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$1.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$2.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$2.class
new file mode 100644
index 0000000..8df5088
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks$2.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks.class
new file mode 100644
index 0000000..4217f54
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/bricks/MainBricks.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Background.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Background.class
new file mode 100644
index 0000000..04be57a
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Background.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Ball.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Ball.class
new file mode 100644
index 0000000..daad877
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/Ball.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$1.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$1.class
new file mode 100644
index 0000000..b7d984b
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$1.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$2.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$2.class
new file mode 100644
index 0000000..fd98894
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles$2.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles.class
new file mode 100644
index 0000000..cfa4e35
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/circles/MainCircles.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/CanvasListener.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/CanvasListener.class
new file mode 100644
index 0000000..7656d51
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/CanvasListener.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/GameObject.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/GameObject.class
new file mode 100644
index 0000000..846d55f
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/GameObject.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/MainCanvas.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/MainCanvas.class
new file mode 100644
index 0000000..4249a7a
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/MainCanvas.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/Sprite.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/Sprite.class
new file mode 100644
index 0000000..71ebe9d
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lb/online/engines/common/Sprite.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/CollectionsHome.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/CollectionsHome.class
new file mode 100644
index 0000000..0a63047
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/CollectionsHome.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Person.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Person.class
new file mode 100644
index 0000000..de6623b
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Person.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Phonebook.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Phonebook.class
new file mode 100644
index 0000000..ff4d994
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/home/Phonebook.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/Box.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/Box.class
new file mode 100644
index 0000000..a17bcab
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/Box.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/MainCollections.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/MainCollections.class
new file mode 100644
index 0000000..f5cd063
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lc/online/MainCollections.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$1.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$1.class
new file mode 100644
index 0000000..5ae7ac4
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$1.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$2.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$2.class
new file mode 100644
index 0000000..e6c2cff
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI$2.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI.class
new file mode 100644
index 0000000..fb7dfb1
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/client/ClientGUI.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/core/ChatServer.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/core/ChatServer.class
new file mode 100644
index 0000000..46be6cb
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/core/ChatServer.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI$1.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI$1.class
new file mode 100644
index 0000000..1838348
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI$1.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI.class
new file mode 100644
index 0000000..f861244
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/ld/online/server/gui/ServerGUI.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/home/CalcThread.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/home/CalcThread.class
new file mode 100644
index 0000000..c88158c
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/home/CalcThread.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/home/Main.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/home/Main.class
new file mode 100644
index 0000000..40f74e0
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/home/Main.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/online/Main.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/online/Main.class
new file mode 100644
index 0000000..a117ed2
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/online/Main.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/online/MyThread.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/online/MyThread.class
new file mode 100644
index 0000000..7560452
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/online/MyThread.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/online/network/ServerSocketThread.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/online/network/ServerSocketThread.class
new file mode 100644
index 0000000..ba9da3e
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/le/online/network/ServerSocketThread.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/EchoServer.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/EchoServer.class
new file mode 100644
index 0000000..4af6742
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/EchoServer.class differ
diff --git a/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/SimpleClient.class b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/SimpleClient.class
new file mode 100644
index 0000000..5fa0b42
Binary files /dev/null and b/untitled9/out/production/J2_Stream200303/ru/gb/jtwo/lf/online/SimpleClient.class differ
diff --git a/untitled9/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$1.class b/untitled9/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$1.class
new file mode 100644
index 0000000..b55de87
Binary files /dev/null and b/untitled9/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$1.class differ
diff --git a/untitled9/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$2.class b/untitled9/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$2.class
new file mode 100644
index 0000000..a127fdd
Binary files /dev/null and b/untitled9/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI$2.class differ
diff --git a/untitled9/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI.class b/untitled9/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI.class
new file mode 100644
index 0000000..a8451c8
Binary files /dev/null and b/untitled9/out/production/chat-client/ru/gb/jt/chat/client/ClientGUI.class differ
diff --git a/untitled9/out/production/chat-library/ru/gb/jt/chat/library/Library.class b/untitled9/out/production/chat-library/ru/gb/jt/chat/library/Library.class
new file mode 100644
index 0000000..38c3e9c
Binary files /dev/null and b/untitled9/out/production/chat-library/ru/gb/jt/chat/library/Library.class differ
diff --git a/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServer.class b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServer.class
new file mode 100644
index 0000000..d9bdd2e
Binary files /dev/null and b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServer.class differ
diff --git a/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServerListener.class b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServerListener.class
new file mode 100644
index 0000000..3e768cf
Binary files /dev/null and b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/ChatServerListener.class differ
diff --git a/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/ClientThread.class b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/ClientThread.class
new file mode 100644
index 0000000..337a5e7
Binary files /dev/null and b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/ClientThread.class differ
diff --git a/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/SqlClient.class b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/SqlClient.class
new file mode 100644
index 0000000..9d1f902
Binary files /dev/null and b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/core/SqlClient.class differ
diff --git a/untitled9/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI$1.class b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI$1.class
new file mode 100644
index 0000000..74349b5
Binary files /dev/null and b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI$1.class differ
diff --git a/untitled9/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI.class b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI.class
new file mode 100644
index 0000000..0bb3f75
Binary files /dev/null and b/untitled9/out/production/chat-server/ru/gb/jt/chat/server/gui/ServerGUI.class differ
diff --git a/untitled9/out/production/network/ru/gb/jt/network/ServerSocketThread.class b/untitled9/out/production/network/ru/gb/jt/network/ServerSocketThread.class
new file mode 100644
index 0000000..e7e88e9
Binary files /dev/null and b/untitled9/out/production/network/ru/gb/jt/network/ServerSocketThread.class differ
diff --git a/untitled9/out/production/network/ru/gb/jt/network/ServerSocketThreadListener.class b/untitled9/out/production/network/ru/gb/jt/network/ServerSocketThreadListener.class
new file mode 100644
index 0000000..710e23d
Binary files /dev/null and b/untitled9/out/production/network/ru/gb/jt/network/ServerSocketThreadListener.class differ
diff --git a/untitled9/out/production/network/ru/gb/jt/network/SocketThread.class b/untitled9/out/production/network/ru/gb/jt/network/SocketThread.class
new file mode 100644
index 0000000..961b4a9
Binary files /dev/null and b/untitled9/out/production/network/ru/gb/jt/network/SocketThread.class differ
diff --git a/untitled9/out/production/network/ru/gb/jt/network/SocketThreadListener.class b/untitled9/out/production/network/ru/gb/jt/network/SocketThreadListener.class
new file mode 100644
index 0000000..348a90b
Binary files /dev/null and b/untitled9/out/production/network/ru/gb/jt/network/SocketThreadListener.class differ