📄 clientreceivethread.java
字号:
/*
* ClientReceiveThread.java
*
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author codewar1
*/
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.io.*;
import java.net.*;
public class ClientReceiveThread extends Thread{
private JTextArea jShow;
Socket socket;
ObjectOutputStream output;
ObjectInputStream input;
//OutputStream output;
iu IU;
//InputStream input;
String name;
// byte[] bytes = new byte[1024];
/** Creates a new instance of ClientReceiveThread */
public ClientReceiveThread(
Socket socket,
ObjectOutputStream output,
ObjectInputStream input,
// OutputStream output,
// InputStream input,
JTextArea jShow,
String name,
iu IU
)
{
this.socket = socket;
this.output = output;
this.input = input;
this.jShow = jShow;
this.name = name;
this.IU = IU;
}
public void run()
{
jShow.append(name+"\n");
// if (!socket.isInputShutdown())jShow.append("input is shutdown");
// if (!socket.isClosed())jShow.append("socket is shutdown");
while(!socket.isClosed())
{ //jShow.append("fwu1");
try
{
// jShow.append("fwu2");
//String type = (String)input.readObject();
// String type = read();
String type = IU.decrypt((String)input.readObject());
//jShow.append(type);
if (type.equalsIgnoreCase("服务器"))
{//判断消息类型
// String sysmsg = (String)input.readObject();
// String sysmsg = read();
//jShow.append("fwu3");
String sysmsg = IU.decrypt((String)input.readObject());
jShow.append("服务器:"+sysmsg+"\n");
}
else if (type.equalsIgnoreCase("shutdown"))
{//关闭
output.close();
input.close();
socket.close();
jShow.append("server is shutdowned"+"\n");
break;
}
}
catch(Exception e)
{
// jShow.append("fwu7");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -