Quicklaunch/QuickLaunch/src/mod_ipchat/ChatOutThread.java
2019-04-14 12:18:58 +02:00

67 lines
1.5 KiB
Java

package mod_ipchat;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;
public class ChatOutThread
implements Runnable {
Scanner scn = new Scanner(System.in);
DataOutputStream out;
String msg = "";
boolean kill = false;
public ChatOutThread(Socket socket) {
try {
this.out = new DataOutputStream(socket.getOutputStream());
}
catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void run() {
block : do {
try {
do {
this.msg = this.scn.nextLine();
this.out.writeUTF(this.msg);
if (!this.kill) continue;
this.out.close();
break block;
} while (!this.msg.equalsIgnoreCase("xxx"));
this.out.close();
break;
}
catch (IOException e) {
e.printStackTrace();
continue;
}
} while (true);
System.out.println("Chatout Done");
}
public String getMsg() {
return this.msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public boolean isKill() {
return this.kill;
}
public void setKill(boolean kill) {
this.kill = kill;
}
}