cclientthread.java
来自「windows系统下用java开发的网络入侵检测程序」· Java 代码 · 共 149 行
JAVA
149 行
import java.io.*;
/**
* Send register or signin request to JIDX Server,if success open CmainFrame.
* <p>
* 2005.8.20
* @version 0.1.2
* @author Daxin Tian
*
*/
public class CclientThread extends Thread{
/**
* Prompt error information.
*/
MsgDialog md_ct=new MsgDialog();
/**
* JIDX Client main window.
*/
CmainFrame c_mf;
/**
* Client's DataInputStream.
*/
DataInputStream c_dis=null;
/**
* Client's DataOutputStream.
*/
DataOutputStream c_dos=null;
/**
* User name which will be sent to JIDX Server.
*/
String c_name=null;
/**
* User password which will be sent to JIDX Server.
*/
String c_password=null;
/**
* Parse XML messages.
*/
XMLParser xp=new XMLParser();
/**
* Received JIDX Server's back messages.
*/
String c_in=null;
/**
* JIDX Client's first window,where user input the JIDX Server's IP address
* ,username and password.
*/
CenterFrame c_cef;
/**
*
* @param dis Client's DataInputStream.
* @param dos Client's DataOutputStream.
* @param name User name which will be sent to JIDX Server.
* @param password User password which will be sent to JIDX Server.
* @param cef JIDX Client's first window,where user input the JIDX Server's IP address
* ,username and password.
*/
CclientThread(DataInputStream dis,DataOutputStream dos, String name, String password,CenterFrame cef)
{
c_dis=dis;
c_dos=dos;
c_name=name;
c_password=password;
c_cef=cef;
}
/**
* The thread continued to read the server's back messages and transact them.
*/
public void run()
{
while(true)
{
try
{
c_in=c_dis.readUTF();
//System.out.println(c_in);
c_parser();
break;
}
catch(IOException e)
{
System.out.println("client read error:"+e);
//Thread.currentThread().yield();
break;
}
}
}
/**
* Use XMLParser parse XML message.
*
*/
public void c_parser()
{
xp.in=new StringBufferInputStream(c_in);
xp.parser();
if(xp.ok_b)
{
xp.ok_b=false;
switch(xp.ok_i)
{
case 1:
System.out.println("register ok");
c_mf=new CmainFrame("JIDX_CLIENT",c_dis,c_dos,c_name);
c_mf.setVisible(true);
break;
case 2:
System.out.println("signin ok");
c_mf=new CmainFrame("JIDX_CLIENT",c_dis,c_dos,c_name);
c_mf.setVisible(true);
break;
}
}
if(xp.error_b)
{
xp.error_b=false;
switch(xp.err_i)
{
case 1:
c_cef.setVisible(true);
md_ct.show(xp.err_info);
break;
case 2:
c_cef.setVisible(true);
md_ct.show(xp.err_info);
break;
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?