Merge origin/master
Conflicts: src/wuerfelthreads/Start.java src/wuerfelthreads/view/WuerfelView.form src/wuerfelthreads/view/WuerfelView.java
This commit is contained in:
parent
d31b791bd9
commit
f4ca6302e7
@ -43,7 +43,6 @@ public class Start
|
|||||||
ReceiveAdapter recAdapter = new ReceiveAdapter(view, model);
|
ReceiveAdapter recAdapter = new ReceiveAdapter(view, model);
|
||||||
recAdapter.subscribe();
|
recAdapter.subscribe();
|
||||||
|
|
||||||
view.setVisible(true);
|
|
||||||
view.setTitle("Chat");
|
view.setTitle("Chat");
|
||||||
|
|
||||||
view.setSize(800, 600);
|
view.setSize(800, 600);
|
||||||
|
@ -14,6 +14,7 @@ import graphicChat.model.ChatModel;
|
|||||||
import graphicChat.model.Figure;
|
import graphicChat.model.Figure;
|
||||||
import graphicChat.view.ChatView;
|
import graphicChat.view.ChatView;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +48,6 @@ public class CommandSend implements ActionListener
|
|||||||
if(src == view.getBtnSend()){
|
if(src == view.getBtnSend()){
|
||||||
/* view get figures*/
|
/* view get figures*/
|
||||||
msg = model.getFigures();
|
msg = model.getFigures();
|
||||||
|
|
||||||
model.sendMessage(msg);
|
model.sendMessage(msg);
|
||||||
view.getLblStatus().setText("Nachricht gesendet");
|
view.getLblStatus().setText("Nachricht gesendet");
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,9 +44,11 @@ public class ChatModel implements Runnable
|
|||||||
|
|
||||||
List<Figure> msg;
|
List<Figure> msg;
|
||||||
|
|
||||||
BufferedReader in;
|
// BufferedReader in;
|
||||||
PrintWriter out;
|
// PrintWriter out;
|
||||||
ObjectInputStream objectisr;
|
|
||||||
|
ObjectOutputStream objectOutput;
|
||||||
|
ObjectInputStream objectInput;
|
||||||
|
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
|
|
||||||
@ -77,7 +80,8 @@ public class ChatModel implements Runnable
|
|||||||
try {
|
try {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
msg = (List<Figure>)objectisr.readObject();
|
lg.info("test");
|
||||||
|
msg = (List<Figure>)objectInput.readObject();
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex)
|
catch (ClassNotFoundException ex)
|
||||||
{
|
{
|
||||||
@ -92,36 +96,31 @@ public class ChatModel implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSocket(Socket s) throws IOException {
|
public void setSocket(Socket s) throws IOException
|
||||||
lg.info("start communication\n");
|
{
|
||||||
InputStream iStream = s.getInputStream();
|
InputStream iStream = s.getInputStream();
|
||||||
OutputStream oStream = s.getOutputStream();
|
OutputStream oStream = s.getOutputStream();
|
||||||
|
|
||||||
ObjectInputStream oisr = new ObjectInputStream(iStream);
|
objectOutput = new ObjectOutputStream(oStream);
|
||||||
InputStreamReader isr = new InputStreamReader(iStream, "UTF-8");
|
// objectOutput.writeObject(msg);
|
||||||
OutputStreamWriter osr = new OutputStreamWriter(oStream, "UTF-8");
|
|
||||||
|
|
||||||
|
objectInput = new ObjectInputStream(iStream);
|
||||||
// BufferedWriter out = new BufferedWriter(osr);
|
|
||||||
objectisr = oisr;
|
|
||||||
out = new PrintWriter(osr);
|
|
||||||
in = new BufferedReader(isr);
|
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClient(int PORT, String IP_ADRESSE) throws IOException
|
public void setClient(int PORT, String IP_ADRESSE) throws IOException
|
||||||
{
|
{
|
||||||
Thread connectThread;
|
Thread connectThread = new Thread(new Runnable() {
|
||||||
connectThread = new Thread(new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
lg.info("Client: verbinde ...");
|
lg.info("Client: verbinde ...");
|
||||||
Socket s = new Socket(IP_ADRESSE, PORT); // Achtung: blockiert!
|
Socket s = new Socket(IP_ADRESSE, PORT); // Achtung: blockiert!
|
||||||
lg.info("Client: Verbindung hergestellt");
|
|
||||||
setSocket(s);
|
setSocket(s);
|
||||||
} catch (IOException e) {
|
lg.info("Client: Verbindung hergestellt");
|
||||||
lg.info("io exception in setClient");
|
} catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
lg.info("Client: Verbindung fehlgeschlagen: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -138,10 +137,11 @@ public class ChatModel implements Runnable
|
|||||||
ServerSocket sSocket = new ServerSocket(PORT);
|
ServerSocket sSocket = new ServerSocket(PORT);
|
||||||
lg.info("Server: Warte auf Verbindung ...");
|
lg.info("Server: Warte auf Verbindung ...");
|
||||||
Socket s = sSocket.accept(); // Achtung: blockiert!
|
Socket s = sSocket.accept(); // Achtung: blockiert!
|
||||||
lg.info("Server: Verbindung akzeptiert");
|
|
||||||
setSocket(s);
|
setSocket(s);
|
||||||
|
lg.info("Server: Verbindung akzeptiert");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
lg.info("io exception in setServer");
|
// e.printStackTrace();
|
||||||
|
lg.info("Server: Verbindung fehlgeschlagen: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -152,8 +152,15 @@ public class ChatModel implements Runnable
|
|||||||
{
|
{
|
||||||
if(laufend){
|
if(laufend){
|
||||||
lg.log(Level.INFO, "Sende Nachricht: ");
|
lg.log(Level.INFO, "Sende Nachricht: ");
|
||||||
out.println(msg);
|
try
|
||||||
out.flush();
|
{
|
||||||
|
objectOutput.writeObject(msg);
|
||||||
|
//objectOutput.flush();
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
Logger.getLogger(ChatModel.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
lg.log(Level.INFO, "Keine Verbindung!");
|
lg.log(Level.INFO, "Keine Verbindung!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user