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

Variable Index

 o dis
Where to get information from the Server
 o dos
Where to send information to the ClientHandler
 o s
The Socket on which the Server listens, the network connection

Constructor Index

 o BOClient()
Creates a client which is connected to the BOServer.

Method Index

 o available()
Returns the number of bytes that can be read from the input stream connected to the Server without blocking
 o cleanUp()
A method used to flush() the DataOutputStream.
 o read()
Reads one int from the Server.
 o readTag()
Reads one int from the Server.
 o send(int)
Sends the specified int to the ClientHandler connected by the DataOutputStream.
 o sendCoords(int, int)
Sends two ints, x and y coordinates, to the ClientHandler connected by the DataOutputStream.

Variables

 o s
 private java.net.Socket s
The Socket on which the Server listens, the network connection

 o dis
 private java.io.DataInputStream dis
Where to get information from the Server

 o dos
 private java.io.DataOutputStream dos
Where to send information to the ClientHandler

Constructors

 o 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.

Methods

 o 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
 o 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
 o 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
 o 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
 o 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
 o cleanUp
 public void cleanUp()
A method used to flush() the DataOutputStream.

See Also:
flush

All Packages  Class Hierarchy  This Package  Previous  Next  Index