chatter.java

来自「java3D game engine design of the source 」· Java 代码 · 共 46 行

JAVA
46
字号

// 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 + =
减小字号Ctrl + -
显示快捷键?