SOMA.network.connection
Class Connection

java.lang.Object
  extended bySOMA.network.connection.Connection
All Implemented Interfaces:
Daemon, java.lang.Runnable
Direct Known Subclasses:
SelfConnection

public class Connection
extends java.lang.Object
implements Daemon, java.lang.Runnable

Demone responsabile delle comunicazioni via socket con un altro place.

Author:
Livio Profiri
See Also:
NewClientExplorerItem

Field Summary
(package private)  Environment env
           
(package private)  java.lang.String ErrorDescription
           
(package private)  java.lang.Thread myDaemon
           
(package private)  java.io.ObjectInputStream myObjectInputStream
           
(package private)  java.io.ObjectOutputStream myObjectOutputStream
           
(package private)  java.net.Socket mySocket
           
(package private)  java.lang.Object status
           
 
Fields inherited from interface SOMA.network.connection.Daemon
ERROR, OFF, ON
 
Constructor Summary
protected Connection()
          Costruttore vuoto.
  Connection(java.net.Socket mySocket, Environment env)
          Costruttore: effettua le inizializzazioni ed apre gli stream della socket.
 
Method Summary
 java.io.InputStream getIn()
          Restituisce l'input stream della socket.
 java.io.OutputStream getOut()
          Restituisce l'output stream della socket.
 java.lang.Object getStatus()
          restituisce lo stato della connessione.
 void run()
          Metodo eseguito dal demone: attende comandi e li esegue finche' lo stato rimane ON e la socket attiva.
 void send(Command c)
          Spedisce un comando.
 void start()
          Avvia il demone in ascolto sull'InputStream della socket.
 void stop()
          Arresta il demone: chiude la socket e gli stream aperti, lo stato va a OFF.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myDaemon

java.lang.Thread myDaemon

mySocket

java.net.Socket mySocket

myObjectInputStream

java.io.ObjectInputStream myObjectInputStream

myObjectOutputStream

java.io.ObjectOutputStream myObjectOutputStream

status

java.lang.Object status

ErrorDescription

java.lang.String ErrorDescription

env

Environment env
Constructor Detail

Connection

protected Connection()
Costruttore vuoto.


Connection

public Connection(java.net.Socket mySocket,
                  Environment env)
Costruttore: effettua le inizializzazioni ed apre gli stream della socket.

Parameters:
mySocket - Socket utilizzata per le comunicazioni.
env - Riferimento all'environment del place.
Method Detail

getIn

public java.io.InputStream getIn()
Restituisce l'input stream della socket.


getOut

public java.io.OutputStream getOut()
Restituisce l'output stream della socket.


getStatus

public java.lang.Object getStatus()
restituisce lo stato della connessione.

Specified by:
getStatus in interface Daemon

start

public void start()
           throws ConnectionException
Avvia il demone in ascolto sull'InputStream della socket.

Specified by:
start in interface Daemon
Throws:
ConnectionException

stop

public void stop()
          throws java.lang.Exception
Arresta il demone: chiude la socket e gli stream aperti, lo stato va a OFF.

Specified by:
stop in interface Daemon
Throws:
java.lang.Exception

toString

public java.lang.String toString()

send

public void send(Command c)
          throws java.io.IOException,
                 ConnectionException
Spedisce un comando.

Throws:
java.io.IOException
ConnectionException

run

public void run()
Metodo eseguito dal demone: attende comandi e li esegue finche' lo stato rimane ON e la socket attiva.

Specified by:
run in interface java.lang.Runnable


Copyright © 2004 Luca Foschini