1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
import waba.io.*;
import waba.io.Socket;
import waba.ui.*;
public class FenPrincipale extends MainWindow
{
Button pan;
int Réponse;
Socket s;
public FenPrincipale()
{
super("Client test", MainWindow.NO_BORDER);
}
public void onStart()
{
pan = new Button("Est-ce que ca va marché?");
add(pan, 50, 20);
setVisible(true);
}
public void onEvent(Event event)
{
if (event.type == ControlEvent.PRESSED)
{
// Creation de la connection
s = new Socket ("172.16.24.124", 8080);
//Création d'un flux de sortie
DataStream out = new DataStream(s);
//Envoie de la réponse au client
out.writeInt(56);
DataStream in = new waba.io.DataStream(s);
Réponse = in.readInt();
pan.setText(""+Réponse);
}
}
} |