Purple Code

com.purpletech.message
Class BlockingPeer

java.lang.Object
  |
  +--com.purpletech.message.AbstractPeer
        |
        +--com.purpletech.message.BlockingPeer
All Implemented Interfaces:
MessagePeer, java.lang.Runnable
Direct Known Subclasses:
StallingPeer

public class BlockingPeer
extends AbstractPeer

A blocking message peer.

connect() starts a thread that listens for incoming messages

Version:
$Id: BlockingPeer.java,v 1.3 2002/11/24 05:32:55 alex Exp $
Author:
Alex Chaffee

Field Summary
protected  java.lang.String host
           
protected  int port
           
 
Fields inherited from class com.purpletech.message.AbstractPeer
doSendSystemMessages, listeners, outPrint, printer
 
Constructor Summary
BlockingPeer(java.lang.String host, int port, MessagePeerPrinter printer)
           
BlockingPeer(java.lang.String host, int port, java.io.PrintStream outPrint)
           
BlockingPeer(java.lang.String host, MessagePeerPrinter printer)
           
BlockingPeer(java.lang.String host, java.io.PrintStream outPrint)
           
 
Method Summary
 void connect()
          Try to connect to the network
 void disconnect()
          Try to disconnect from the server
 java.lang.String getHost()
           
protected  java.io.InputStream getInputStream()
          subclasses can override this to provide filters on the input stream
protected  java.io.OutputStream getOutputStream()
          subclasses can override this to provide filters on the output stream
 int getPort()
           
 boolean isConnected()
          are we connected or not?
 Message receiveMessage()
          Actively receive a message.
 void sendMessage(Message msg)
          sends a message out across the pipe
 
Methods inherited from class com.purpletech.message.AbstractPeer
addMessageListener, bind, getID, lookup, processSystemMessage, removeMessageListener, run, setSendSystemMessages, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host

protected java.lang.String host

port

protected int port
Constructor Detail

BlockingPeer

public BlockingPeer(java.lang.String host,
                    int port,
                    MessagePeerPrinter printer)

BlockingPeer

public BlockingPeer(java.lang.String host,
                    int port,
                    java.io.PrintStream outPrint)

BlockingPeer

public BlockingPeer(java.lang.String host,
                    MessagePeerPrinter printer)

BlockingPeer

public BlockingPeer(java.lang.String host,
                    java.io.PrintStream outPrint)
Method Detail

getHost

public java.lang.String getHost()

getPort

public int getPort()

getOutputStream

protected java.io.OutputStream getOutputStream()
                                        throws java.io.IOException
subclasses can override this to provide filters on the output stream

java.io.IOException

getInputStream

protected java.io.InputStream getInputStream()
                                      throws java.io.IOException
subclasses can override this to provide filters on the input stream

java.io.IOException

connect

public void connect()
             throws java.io.IOException
Try to connect to the network

Specified by:
connect in interface MessagePeer
Specified by:
connect in class AbstractPeer
java.io.IOException

disconnect

public void disconnect()
Description copied from interface: MessagePeer
Try to disconnect from the server

Specified by:
disconnect in interface MessagePeer
Specified by:
disconnect in class AbstractPeer

sendMessage

public void sendMessage(Message msg)
sends a message out across the pipe

Specified by:
sendMessage in interface MessagePeer
Specified by:
sendMessage in class AbstractPeer

receiveMessage

public Message receiveMessage()
Actively receive a message. Blocks until a message arrives.

Usually don't call this method; instead, call addMessageListener and wait for a notification.

Specified by:
receiveMessage in class AbstractPeer
Returns:
null if there is no message waiting

isConnected

public boolean isConnected()
Description copied from interface: MessagePeer
are we connected or not?

Specified by:
isConnected in interface MessagePeer
Specified by:
isConnected in class AbstractPeer

Documentation generated March 5 2003