71
}
ss.sendTipe5RoutingTableConverter.TableToStringdata Table;
}
mula-mula membentuk array data dengan matrik 3x1 untuk menampung data inputan dari tipe 4. Mula-mula cek apakah tabel
utama tidak sama dengan null, jika iya maka cek kembali apakah ip destinasi nya sudah ada dalam tabel, jika sudah ada maka data tidak
dimasukkan, jika tidak ada maka data dimasukkan. Jika tabel utama masih berisi null , maka data dimasukan ke dalam tabel. Kemudian
data dalam tabel diubah dalam bentuk matrik dua dimensi untuk keperluan pengiriman isi tabel yang ditampung dalam array
dataTabel[][].
4.4 Class SendServer.java
Merupakan server pengirim yang mempunyai fungsi sebagai client side
dari sistem pencarian jalur evakuasi ini. Server ini bertugas untuk mengirimkan data sesuai dengan permintaan. Struktur kelas
pada SendServer.java:
4.4.1 olahDataversi,ipaddr,ipdest,hop
Merupakan method dengan parameter String versi, String ipAddr, String ipDest dan String hop yang berguna untuk pengumpul
data, yang kemudian akan dikirim dalam satu string.
public void olahDataString versi, String ipaddr, String ipdes, String hop {
this.versi = versi;
72
this.ipAddr = ipaddr; this.ipDest = ipdes;
this.hop = hop; }
4.4.2 sendTipe2
Merupakan method yang berfungsi untuk mengirimkan method tipe 2.
public void sendTipe2 { try {
final Socket s2 = new SocketipDest, portTipe1;
Runnable set = new Runnable { public void run {
Get output stream associated with the socket
OutputStream s1out = null; try {
s1out = s2.getOutputStream; BufferedWriter bw = new
BufferedWriternew OutputStreamWriters1out; Send your string
bw.writeversi + + dua + + ipAddr + + ipDest + + hop;
Close the connection, but not the server socket
bw.close; s2.close;
} catch IOException ex { } finally {
try { s1out.close;
} catch IOException ex {
73
} }
} };
Thread th = new Threadset; th.start;
} catch UnknownHostException ex { } catch IOException ex {
JOptionPane.showMessageDialognull, SERVER + ipDest + GAGAL DIHUBUNGI;
} }
4.4.3 sendTipe3String
Merupakan method yang berfungsi untuk mengirim paket data tipe 5.
public void sendTipe5final String s { try {
final Socket s5 = new SocketipDest, portTipe1;
Runnable set = new Runnable { public void run {
Get output stream associated with the socket
OutputStream s1out = null; try {
s1out = s5.getOutputStream; BufferedWriter bw = new
BufferedWriternew OutputStreamWriters1out; Send your string
bw.writeversi + + Type5 + + ipAddr + + s;
74
Close the connection, but not the server socket
bw.close; s5.close;
} catch IOException ex { } finally {
try { s1out.close;
} catch IOException ex { }
} }
}; Thread th = new Threadset;
th.start; } catch UnknownHostException ex {
} catch IOException ex { JOptionPane.showMessageDialognull, SERVER
+ ipDest + GAGAL DIHUBUNGI; }
} }
4.5 Class ReceivedServer.java
Kelas ReceivedServer.java berfungsi untuk menerima informasi data, yang kemudian data tersebut dilempar ke kelas
programUtama.java untuk diolah.
4.5.1 responServer programUtama
Merupakan method yang digunakan untuk membuka socket untuk menerima data dalam bentuk String.
Register your service on port 9000