CS101 Package Problem Set Javadocs

cs101.net
Class BabySitter

java.lang.Object
  extended bycs101.net.BabySitter
All Implemented Interfaces:
java.lang.Runnable

public class BabySitter
extends java.lang.Object
implements java.lang.Runnable

This object handles the io between the server and one client. It has a run method that listens for information and relays it to the server. It also has a method to send information back to its client.

Copyright 1998 Massachusetts Institute of Technology

Version:
$Id: BabySitter.java,v 1.2 2003/09/23 15:18:08 gus Exp $
Author:
Todd C. Panrell, tparnell@ai.mit.edu

Field Summary
protected  java.io.ObjectInputStream ois
          Where to read from client
protected  java.io.ObjectOutputStream oos
          Where to write to client
protected  Server server
          Server this client is connected to
protected  java.net.Socket sock
          Client connection
protected  java.lang.Thread spirit
          Animacy that runs this object
 
Constructor Summary
protected BabySitter(java.net.Socket sock, Server server)
          Creates a BabySitter to handle communication with a client.
 
Method Summary
 void run()
          Recieves new info from clients.
protected  void send(java.lang.String s)
          Sends a String to the client.
protected  void stop()
          Should only be called by Server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected Server server
Server this client is connected to


spirit

protected java.lang.Thread spirit
Animacy that runs this object


sock

protected java.net.Socket sock
Client connection


ois

protected java.io.ObjectInputStream ois
Where to read from client


oos

protected java.io.ObjectOutputStream oos
Where to write to client

Constructor Detail

BabySitter

protected BabySitter(java.net.Socket sock,
                     Server server)
Creates a BabySitter to handle communication with a client. Spawns a new thread to handle input from client; sends strings on request.

Parameters:
sock - the client socket of this threads client
server - The Server object for this BabySitter
See Also:
send(java.lang.String), Server.sendToAllExcept(java.lang.String, cs101.net.BabySitter)
Method Detail

send

protected void send(java.lang.String s)
Sends a String to the client.

Parameters:
s - the String to send

run

public void run()
Recieves new info from clients.

Specified by:
run in interface java.lang.Runnable
See Also:
Server.sendToAllExcept(java.lang.String, cs101.net.BabySitter)

stop

protected void stop()
Should only be called by Server. User server.removeBabySittter( BabySitter ) instead.

See Also:
Server.removeBabySitter(cs101.net.BabySitter)

CS101 Package Problem Set Javadocs