All Packages Class Hierarchy This Package Previous Next Index
Class breakout.BOClient
java.lang.Object
|
+----breakout.BOClient
- public class BOClient
- extends java.lang.Object
A class which has methods to read and write. Works with BOServer.java and ClientHandler.java.
Uses Gamefinder, created by Mike Wessler, to get the hostname and port.
- Author:
- Jennifer Shieh
- See Also:
- java.lang.Runnable, breakout.BOServer, breakout.ClientHandler
-
dis
- Where to get information from the Server
-
dos
- Where to send information to the ClientHandler
-
s
- The Socket on which the Server listens, the network connection
-
BOClient()
- Creates a client which is connected to the BOServer.
-
available()
- Returns the number of bytes that can be read from the input stream connected to the Server without blocking
-
cleanUp()
- A method used to flush() the DataOutputStream.
-
read()
- Reads one int from the Server.
-
readTag()
- Reads one int from the Server.
-
send(int)
- Sends the specified int to the ClientHandler connected by the DataOutputStream.
-
sendCoords(int, int)
- Sends two ints, x and y coordinates, to the ClientHandler connected by the DataOutputStream.
s
private java.net.Socket s
- The Socket on which the Server listens, the network connection
dis
private java.io.DataInputStream dis
- Where to get information from the Server
dos
private java.io.DataOutputStream dos
- Where to send information to the ClientHandler
BOClient
public BOClient()
- Creates a client which is connected to the BOServer. Takes no arguments. It creates a new Socket connected to
the port returned by gl.getPort() on the host with name gl.getAddress(), features of Mike Wessler's GameFinder.
Makes new DataOutputStream and DataInputStream, which are given the OutputStream and InputStream of the Socket
described above.
read
public int read()
- Reads one int from the Server. Returns that int. Generally, either the x or the y coordinate of the ball
- Returns:
- i the int read from the DataInputStream connected to the Server
- See Also:
- readInt
readTag
public int readTag()
- Reads one int from the Server. Returns that int, which represents the current number of players
- Returns:
- i the player ID, or number of players, read from the DataInputStream connected to the Server
- See Also:
- readInt
available
public int available()
- Returns the number of bytes that can be read from the input stream connected to the Server without blocking
- See Also:
- available
send
public void send(int i)
- Sends the specified int to the ClientHandler connected by the DataOutputStream. Flushes after every write.
- Parameters:
- int - i the int which should be sent
- See Also:
- writeInt, flush
sendCoords
public void sendCoords(int x,
int y)
- Sends two ints, x and y coordinates, to the ClientHandler connected by the DataOutputStream. Flushes after every write.
- Parameters:
- int - x the x coordinate to be sent
- int - y the y coordinate to be sent
- See Also:
- writeInt, flush
cleanUp
public void cleanUp()
- A method used to flush() the DataOutputStream.
- See Also:
- flush
All Packages Class Hierarchy This Package Previous Next Index