|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.util.Observable
com.monkeycoder.monkeynetwork.Network
public abstract class Network
This is the super class for all other network objects within the MonkeyNetwork system. Generally this class expects to be observed by a class outside of the MonkeyNetwork system and to observe its ProtocolStateEngine.
This class uses monkeynetwork.ini and requires the following
parameters:
connect_timeout - Time in milliseconds before a connection attempt times out.
| Field Summary | |
|---|---|
protected java.net.InetSocketAddress |
conAddr
The underlying InetSocketAddress used to create the connection. |
protected java.io.InputStream |
inStream
The underlying InputStream. |
protected java.io.OutputStream |
outStream
The underlying OutputStream. |
protected java.net.Socket |
sock
The underlying Socket. |
protected ProtocolStateEngine |
stateEngine
The underlying state engine |
| Constructor Summary | |
|---|---|
protected |
Network()
Super Constructor, this is where Network type inspecific things are done. |
| Method Summary | |
|---|---|
protected void |
connect()
Connects this network. |
protected void |
disconnect()
Disconnects this network. |
abstract void |
fetch(java.lang.String inUri)
Fetches web content via the transport medium specified by this network. |
java.io.InputStream |
getContent()
Gets the downloaded content. |
java.lang.String |
getEndpointHost()
Get the host of the Endpoint. |
int |
getEndpointPort()
Get the port of the Endpoint. |
protected java.io.InputStream |
getInputStream()
Gets an InputStream for this network connection. |
abstract int |
getNetworkProtocol()
Get the protocol of this network object. |
protected java.io.OutputStream |
getOutputStream()
Gets an OutputStream for this network connection. |
boolean |
isConnected()
Check to see whether this network is presently connected. |
void |
setEndpoint(java.lang.String inHost,
int inPort)
Set the Endpoint of this connection. |
abstract void |
update(java.util.Observable inObservable,
java.lang.Object inArg)
Used by the network state engine to pass messages to this class. |
| Methods inherited from class java.util.Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.net.Socket sock
protected java.io.InputStream inStream
protected java.io.OutputStream outStream
protected java.net.InetSocketAddress conAddr
protected ProtocolStateEngine stateEngine
| Constructor Detail |
|---|
protected Network()
| Method Detail |
|---|
protected void connect()
throws java.io.IOException,
MonkeyException
java.io.IOException - If the attempt to connect this network failed.
MonkeyException - If the endpoint of this connection has not been set.
protected void disconnect()
throws java.io.IOException
java.io.IOException - If the attempt to disconnect this network failed. (Genuine
failure to close the socket.)protected java.io.InputStream getInputStream()
null if this
network is not presently connected.protected java.io.OutputStream getOutputStream()
null if this
network is not presently connected.
public void setEndpoint(java.lang.String inHost,
int inPort)
inHost - The host to which this network will be connected.inPort - The port through which this network will be connected.public java.lang.String getEndpointHost()
public int getEndpointPort()
public boolean isConnected()
public java.io.InputStream getContent()
throws java.io.IOException
java.io.IOException - If the underlying TurboBuffer fails to produce an appropriate InputStream.TurboBuffer,
UpdateMessagepublic abstract int getNetworkProtocol()
NetworkProtocol
public abstract void fetch(java.lang.String inUri)
throws java.io.IOException,
MonkeyException
inUri - The content being requested. This is a partial URI based
on the established connection.
java.io.IOException - When thrown by underlying network code.
MonkeyException - If the network is not yet connected.UpdateMessage
public abstract void update(java.util.Observable inObservable,
java.lang.Object inArg)
update in interface java.util.ObserverinObservable - The observable object.inArg - The UpdateMessage passed to the notifyObservers method.UpdateMessage
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||