📄 chatter.java
字号:
// Chatter.java
// Andrew Davison, June 2003 (dandrew@ratree.psu.ac.th)
/* Stores information about a single client:
the client's IP address, port, and output stream
The output stream is used to send messages to the client.
The address and port are used to uniquely identify the
client (the client has no name).
*/
import java.io.*;
public class Chatter
{
private String cliAddr;
private int port;
private PrintWriter out;
public Chatter(String cliAddr, int port, PrintWriter out)
{ this.cliAddr = cliAddr;
this.port = port; this.out = out;
}
public boolean matches(String ca, int p)
// the address and port of a client are used to uniquely identify it
{ if (cliAddr.equals(ca) && (port == p))
return true;
return false;
} // end of matches()
public void sendMessage(String msg)
{ out.println(msg); }
public String toString()
{ return cliAddr + " & " + port + " & "; }
} // end of Chatter class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -