touristinfo.java

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

JAVA
49
字号

// TouristInfo.java
// Andrew Davison, July 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).

  Very similar to Chatter in the multithreaded Chat server.
*/


import java.io.*;


public class TouristInfo
{
  String cliAddr;
  int port;
  PrintWriter out;

  public TouristInfo(String cliAddr, int port, PrintWriter out)
  { this.cliAddr = cliAddr;
    this.port = port; this.out = out;
  }

  public boolean matches(String ca, int p)
  {
    if (cliAddr.equals(ca) && (port == p))
      return true;
    return false;
  }

  public void sendMessage(String msg)
  { // System.out.println("sendMessage to (" + cliAddr + "," +
	//					port + ") : " + msg);
    out.println(msg);  
  }


  // public String toString()
  // {  return cliAddr + " & " + port + " & ";  }


}  // end of TouristInfo class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?