Commit c4199768 authored by mohammadmahdihn's avatar mohammadmahdihn
Browse files

Commit message mowlaei

parent afcf60df
......@@ -5,16 +5,34 @@ import javafx.scene.media.MediaPlayer;
import org.model.*;
import org.view.LoginMenuView;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.net.Socket;
import java.util.ArrayList;
public class MainClient {
private static Socket socket;
private static DataInputStream dataInputStream;
private static DataOutputStream dataOutputStream;
public static void initializeNetwork() {
try {
socket = new Socket("localhost", 7677);
dataInputStream = new DataInputStream(socket.getInputStream());
dataOutputStream = new DataOutputStream(socket.getOutputStream());
} catch (IOException x) {
x.printStackTrace();
}
}
public static void main(String[] args) throws Exception {
restoreDatabase();
new LoginMenuView().run();
initializeNetwork();
dataOutputStream.writeUTF("2");
dataOutputStream.flush();
String result = dataInputStream.readUTF();
System.out.println("4");
// restoreDatabase();
// new LoginMenuView().run();
}
private static void restoreDatabase() throws Exception {
......
......@@ -19,14 +19,14 @@ public class MainServer {
serverSocket = new ServerSocket(7677);
while(true){
Socket socket = serverSocket.accept();
startNewThread(serverSocket, socket);
startNewThread(socket);
}
} catch(Exception e){
e.printStackTrace();
}
}
private static void startNewThread(ServerSocket serverSocket, Socket socket) {
private static void startNewThread(Socket socket) {
new Thread(() -> {
try {
DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
......@@ -47,6 +47,6 @@ public class MainServer {
}
private static String process(String input) {
return null;
return String.valueOf(Integer.parseInt(input) * 2);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment