insa.projets.NetworkPackage
Class Network

java.lang.Object
  extended by insa.projets.NetworkPackage.Network
All Implemented Interfaces:
NetworkInterface

public class Network
extends java.lang.Object
implements NetworkInterface


Field Summary
private  MonitorInterface callBack
           
private  java.io.DataInputStream inStream
           
private  java.io.DataOutputStream outStream
           
private  java.net.Socket serverSocket
           
private  boolean shortMessages
           
private  ListeningThread theThread
           
 
Constructor Summary
Network()
           
 
Method Summary
 void TCPclose()
          Ferme la connexion réseau si elle était ouverte.
 void TCPconnect(java.lang.String IP, int port)
          Initie une connexion réseau en tentant de se connecter au serveur d'adresse IP, sur le port précisé.
 void TCPInit(MonitorInterface callBack, boolean shortMessages)
          Initialisation du module réseau.
 void TCPsend(byte codeOp, short data)
          Envoie d'un message sur le réseau, composé d'un codeOp et d'un paramètre.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serverSocket

private java.net.Socket serverSocket

inStream

private java.io.DataInputStream inStream

outStream

private java.io.DataOutputStream outStream

theThread

private ListeningThread theThread

callBack

private MonitorInterface callBack

shortMessages

private boolean shortMessages
Constructor Detail

Network

public Network()
Method Detail

TCPInit

public void TCPInit(MonitorInterface callBack,
                    boolean shortMessages)
Description copied from interface: NetworkInterface
Initialisation du module réseau. Cette méthode n'a pour rôle que de transmettre un pointeur de callback. L'utilisateur de cette interface réseau doit lui même répondre à l'interface MonitorInterface. Ainsi, Si le module réseau observe une communication nécessitant un retour visuel, il doit pouvoir appeler les méthodes fournies par MonitorInterface.

Ainsi, il suffit que l'utilisateur de ce module réseau soit une implémentation de MonitorInterface et appelle cette méthode avant toute communication réseau par la commande : TCPInit(this).

Specified by:
TCPInit in interface NetworkInterface
Parameters:
callBack - pointeur vers le moniteur pour que le processus de réception des messages puisse prendre l'initiative d'envoyer des informations au programme principal.
shortMessages - vrai si et seulement si le texte affiché doit être court, afin de tenir sur un affichage étroit.

TCPconnect

public void TCPconnect(java.lang.String IP,
                       int port)
                throws java.net.UnknownHostException,
                       java.io.IOException
Description copied from interface: NetworkInterface
Initie une connexion réseau en tentant de se connecter au serveur d'adresse IP, sur le port précisé.

Specified by:
TCPconnect in interface NetworkInterface
Throws:
java.net.UnknownHostException
java.io.IOException

TCPclose

public void TCPclose()
              throws java.io.IOException
Description copied from interface: NetworkInterface
Ferme la connexion réseau si elle était ouverte.

Specified by:
TCPclose in interface NetworkInterface
Throws:
java.io.IOException

TCPsend

public void TCPsend(byte codeOp,
                    short data)
             throws java.io.IOException
Description copied from interface: NetworkInterface
Envoie d'un message sur le réseau, composé d'un codeOp et d'un paramètre.

Specified by:
TCPsend in interface NetworkInterface
Throws:
java.io.IOException