|
Chapter 4: System Implementation
|
<< Page
1
2
3
4
5
6
>> |
4.1.1.1.
ISC Commands Serving
The ISC system defines a set of
commands where each of which is used for a
specific purpose. The following table lists the
ISC commands and their use.
|
ISC
Command |
Description |
|
·
"ISC-CONNECTION-ACCEPTED" |
Indicates that the sign-on process is
successful. |
|
·
"ISC-CONNECTION-SIGNEDON" |
Indicates that the sign-on process was
not successful because the user is
already signed on. |
|
·
"ISC-CONNECTION-REJECTED" |
Indicates that the sign-on process was
unsuccessful due to a failed
authorisation. |
|
·
"ISC-STARTSESSION-111111" |
Alerts other online clients that a new
client has been signed-on. The
screen-name of the new client is
encapsulated within the command object. |
|
·
"ISC-ENDSESSION-010101" |
A client’s request command to sign-off
the system. |
|
·
"ISC-ENDSESSION-000000" |
Alerts online clients that a client has
been signed-off. The screen-name of this
client is encapsulated within the
command object. |
|
·
"ISC-PRTIVATEREQUEST-010101" |
A client’s request for a private session
that is to be sent to the other party
for approval. |
|
·
"ISC-PRTIVATEREQUEST-111111" |
A client’s reply for a private session
request that indicates his/her
acceptance, which is to be sent to the
other party. |
|
·
"ISC-PRTIVATEREQUEST-000000" |
A client’s reply for a private session
request that indicates his/her denial,
which is to be sent to the other party. |
|
·
"ISC-PRTIVATEFILETRANSFERREQUEST-010101" |
A client’s request for a file transfer
session that is to be sent to the other
party for approval. |
|
·
"ISC-PRTIVATEFILETRANSFERREQUEST-111111" |
A client’s reply for a file transfer
session that indicates his/her
acceptance, which is to be sent to the
other party. |
|
·
"ISC-PRTIVATEFILETRANSFERREQUEST-000000" |
A client’s reply for a file transfer
session that indicates his/her denial,
which is to be sent to the other party. |
|
·
"ISC-PRTIVATEVCREQUEST-010101" |
A client’s request for a private voice
conferencing session that is to be sent
to the other party for approval. |
|
·
"ISC-PRTIVATEVCREQUEST-111111" |
A client’s reply for a private voice
conferencing request that indicates
his/her acceptance, which is to be sent
to the other party. |
|
·
"ISC-PRTIVATEVCREQUEST-000000" |
A client’s reply for a private voice
conferencing request that indicates
his/her denial, which is to be sent to
the other party. |
4.2.
ISC Client Application
The ISC Client Application is the
clients’ gateway to the ISC services that are
provided by the ISC Server. As mentioned earlier
in the stages of development, the client
application was developed throughout various
phases aiming to provide a user-friendly
application within the system requirements.
During the development period, the application
was frequently demonstrated to individuals for
further feedback that was used to improve both
of the quality of services and the application
interface. The following titles give a better
view of the final application functions and
layout. Note that a
full coding of the client application is
provided in Appendix B.
4.2.1.
Sign-on Screen
Once the client application is
started, the sign-on screen is loaded. This is a
basic screen that contains two text fields for
the user to enter his/her details prior clicking
on the “CONNECT” button to sign-on the
ISC system.
Figure 4.17: Sign-on screen.
In addition, the screen includes
an “EXIT” button to terminate the
application and free computer resources.
4.2.2.
Public Communication Screen
Once the connection has been
established, the authentication process takes
place. In the case of an unsuccessful
authentication process, a message will be
displayed stating the reason behind the
unsuccessful sign-on process. However, if the
sign-on process was positively carried out, the
public communication screen will be loaded. The
screen contains a variety of AWT components as
shown below.
Figure 4.18: Public communication
screen.
4.2.2.1.
Key to Figure 4.18
(1)
Menu bar
The menu bar adds some functions
to the application where clients can use to
establish file transfer and/or voice
conferencing sessions with another client that
should be selected from the “Users List”.
|
//initialise a new private message
Message message = new
Message("ISC-PRTIVATEFILETRANSFERREQUEST-010101",false);
String user =
users_lst.getSelectedItem();
//get the selected client
if ( !user.equals(me.get_screen_name())
){ //check if it not the same
user of the application
message.setMessageTo(user);
//define the receiver of the
request
send(message);
//transmit message
appendSystemMessage("*
Private file transfer request was
sent to " + message.to
+ ".");
}//close if
else if ( user == null ) {
appendSystemMessage("* You
have to select a user from the
online users list prior”
+ “launching a file transfer
session");
}//close else if
else{
appendSystemMessage("* You
can not send a private file transfer
request to yourself!");
}//close
else
|
Figure 4.19: Transmitting a file
transfer request.
|
Message message = new
Message("ISC-PRTIVATEVCREQUEST-010101",
false);
String user =
users_lst.getSelectedItem();
//get the selected client
if ( !user.equals(me.get_screen_name())
){ //check if it not the same
user of the
application
message.setMessageTo(user);
//define the receiver of the
request
send(message);
//transmit message
appendSystemMessage("*
Private voice conference request was
sent to " + message.to
+ ".");
}//close if
else if ( user == null ) {
appendSystemMessage("* You
have to select a user from the
online users list prior”
+ “launching a
voice conferencing session");
}//close else if
else{
appendSystemMessage("* You
can not send a private voice
conferencing request to
yourself!");
}//close
else
|
Figure 4.20: Transmitting a voice
conferencing request.
(2)
Public communication window
As soon as a public message is
received, the message will be displayed in the
public communication window. It is worth
mentioning that this window is not editable by
the user.
(3)
Message textbox
This textbox is where clients
type their public messages. Once a public
message is typed, the user is required to either
hit the “Enter” key or click on the
“SEND” button in order to transmit the
message. However, the typed message will not be
displayed on the public communication window
until it is received from the server.
(4)
Save log checkbox
This function was added to the
final version of the application based on the
feedback that was received from individuals. The
function required is to enable clients to store
a record of their public conversation when they
desire. Hence, the log is saved as a text file
only if this checkbox is clicked. The file will
be named as follows: month + day + hour +
minute + “.txt”.
|
Date time = new Date(); //get
current time
//create a new text file
String fileName = new String (Integer.toString(time.getMonth())
+ " - " +
Integer.toString(time.getDate())
+ " - " +
Integer.toString(time.getHours())
+ " - " +
Integer.toString(time.getMinutes())
+ ".txt");
PrintWriter fout = new
PrintWriter(new BufferedWriter(new
FileWriter(fileName)));
int count;
comm_label.setText("Saveing
log...");
//save the contents of the vector to
a file
for ( count = 0 ; count <
iscLog.size() ; count++ ){
fout.println((String)iscLog.elementAt(count));
}//close for
fout.close();//close file |
Figure 4.21: Save log.
(5)
Sign-off button
The sign-off button enables
clients to sign-off the system. Consequently,
the communication between the client application
and the server will be closed, as well as, other
communication windows that might be opened, e.g.
private sessions, file transfer sessions, and
voice conferencing sessions. However, prior
closing the communication channel, the
application sends a sign-off command to the
server to terminate its dedicated thread on the
server machine.
|
comm_label.setText("Signing
off...");
//initialise a sign-off command
Message msg = new
Message("ISC-ENDSESSION-010101");
send(msg);
//transmit request
socket.get_socket().close();
//close communication channel
if ( checkbox.getState() ){
saveLog();
//save log if the checkbox is
clicked
}//close if
//terminate private session if
applicable
if ( sessions.numberOfSessions() !=
0 ){
for ( int count = 0 ; count
< sessions.numberOfSessions() ;
count++ ){
sessions.getSession(count).exit();
}//close for
}//close if
//terminate file transfer session if
applicable
if ( FTSession != null ){
FTSession.terminate();
}//close if |
Figure 4.22: Sign-off process.
(6)
Users list
It is essential to list current
online clients to the application users as soon
as the public communication screen is launched.
Therefore, once a client is successfully
authenticated, the application request from the
server to send the current online clients list.
Once the list is received, the application lists
their screen-names on the “Users List”.
It is worth mentioning that users list is
transmitted form the server to the client
application as an instance of the “Users”
class. However, while the client online, the
server alerts the client’s application with the
new signed-on or signed-off clients.
|
String message = new String("* " +
user + " has just signed
on.");
usersList.addUser(user);
//add new user to the vector
appendSystemMessage(message);
users_lst.add(user);
//update users list |
Figure 4.23: Updating users list.
The component allows clients to
select one of the listed online clients.
However, once a client is selected from the list
and his/her screen-name is double clicked, the
screen sends a private session request to the
selected client.
|
//initialise a private session
request
Message message = new
Message("ISC-PRTIVATEREQUEST-010101",
false);
String user =
users_lst.getSelectedItem();
//get the selected client
if ( !user.equals(me.get_screen_name())
){ //check if it is not the user
of the application
message.setMessageTo(user);
//define the receiver
of the request
send(message);
//transmit request
appendSystemMessage("*
Private session request was sent to
" + message.to
+ ".");
}//close if
else{
appendSystemMessage("* You
can not send a private session
request to yourself!");
}//close else |
Figure 4.24: Transmitting a
private session request.
(7)
Last received message time
This function is also added as a
result of the feedback provided by individuals.
They required to add a mean to show the user the
time when the last message was received. Hence,
this component is updated as soon as a public
message is received from the server stating the
current time.
|
Date time = new
Date();
//get current time
msgTime_label.setText("Last message
was recieved at " +
time.getHours() + ":" +
time.getMinutes()
+ ":" +
time.getSeconds());
//update
component |
Figure 4.25: Update the last
received message time component.
(8)
Send button
Once a public message has been
typed by the user and the “SEND” button
is clicked, the message will disappear from the
“Message textbox” and then transmitted to
the server.
|
String message = msg_txt.getText();
//get client’s public message
if ( !message.equals("")
){
//check
if it is not an empty message
Socket client =
socket.get_socket();
//get socket
Message msg = new
Message(message);
//initialise a new public message
ObjectOutputStream o = new
ObjectOutputStream (client.getOutputStream
());
o.writeObject(msg);
//transmit public message
msg_txt.setText("");
//empty
textbox
}//close if |
Figure 4.26: Transmitting public
messages.
(9)
Number of users
This component carries on a basic
function that is to display the number of the
current online clients. This component is
updated each time a client signs-on or off the
system.
|
usersCount_label.setText(Integer.toString(users_lst.countItems())
+ " online user(s)"); |
Figure 4.27: Update the number of
users.
4.2.3.
Private Session Screen
As the ISC system provides the
service of private communication sessions where
two clients can have a conversation in privacy,
it was essential to provide a mean to enable
clients to exchange private messages amongst
each other within an interactive and
user-friendly environment. The ISC private
session screen was designed and implemented to
meet such requirements.
Figure 4.28: Private session
screen.
In the case of a client wishing
to establish a private session with his/her
peer, the client is required to send a private
session request to the other party by either
double clicking on the latter screen name in the
“Users List” or using the “Menu bar”.
On the other hand, the other party is required
to either accept or deny the request. Once the
request is accepted, the ISC private session
screen is launched; otherwise, the client will
be notified that the other party has rejected
his/her request.
Once the private session screen
has been launched, clients can exchange private
messages by typing their messages into the
provided textbox, and then, clicking on the
“SEND” button or just hitting the “Enter”
key. It is worth mentioning that the screen uses
the “send” method that is defined in the
“ISC” class to transmit clients’ private
messages. However, prior transmitting the
message, the screen encapsulates the message
into a “Message” Java object, initialises
the object as a private message, and defines the
sender and the receiver of the message.
|
//get clients message
Message msg = new
Message(msg_txt.getText(), false);
//send message
if ( !msg.msg.equals("") ){
msg.setMessageTo(otherParty);
//define the receiver of the message
isc.send(msg); //use
the “send” method in the “ISC” class
to transmit the message
msg_txt.setText("");
//clear the
textbox component
}//close if |
Figure 4.29: Transmitting private
messages.
The screen also enables clients
to launch the ISC File Transfer Subsystem as
well as the ISC Voice Conferencing Subsystem by
sending an ISC command request to the other
party. Based on the recommendations provided by
individuals, it was recommended that other
party’s application accepts the request without
the approval of its user as the two parties
share a private session. Hence, once the request
is sent to the other party and then the approval
is received, the subsystem will be launched.
|
send(new
Message("ISC-PRTIVATEFILETRANSFERREQUEST-010101",
false));
append(new Message("* Private file
transfer request was sent to " +
getOtherParty() + ".")); |
Figure 4.30: Transmitting file
transfer request.
|
send(new
Message("ISC-PRTIVATEVCREQUEST-010101",
false));
append(new Message("* Private file
transfer request was sent to " +
getOtherParty() + ".")); |
Figure 4.31: Transmitting voice
conferencing request.
In addition, the screen
implements a function to save client’s
conversations into a text file for further
review. The function’s implementation is fairly
similar to the one used in the “Public
Communication Screen”. It uses a Java vector
object to store clients’ messages. However, the
contents of the vector will only be saved to
disk if the “Save Log” checkbox is clicked
before closing the screen.
4.2.4.
File Transfer Screen
One of the primary objectives of
the ISC system is to provide its clients with a
file transfer system that is to enable them to
transfer files amongst each other. The system is
also required to be efficient, interactive, and
a user-friendly one. The ISC File Transfer
Subsystem, which defined in
“FTransferSession” class, was designed and
implemented in a manner that meets clients’
needs. As it is important for the receiver’s
application to ensure that the file that is
being transmitted is fully received, the system
is implemented using TCP/IP Java sockets to
grantee the delivery of transmitted packets.
4.2.4.1.
Start-up Connection
In the case of a client wishing to transfer a
file to his/her peer, a file transfer request is
initialised and transmitted to the other party.
Once the request is received by the other
party’s application, he/she is required to
either accept the request or deny. In case of
the latter, a rejection reply is sent to the
request initiator, and consequently, the file
transfer system will not be launched. However,
once the other party accepts the request, an
acceptance reply along with his/her connection
details, including the IP address, is sent to
the request initiator. In addition, a file
transfer session will be launched on the other
party’s machine. It is worth mentioning that
this process is entirely carried out by the ISC
Message Exchange Subsystem; hence, the message
exchange system plays a major role of
establishing file transfer sessions.
Figure 4.32: Incoming file
transfer request.
As soon as a file transfer session is launched
on the other party’s machine, the file transfer
system creates a “ServerSocket” and waits
for the file sender’s connection. On the other
hand, once the request initiator receives the
acceptance reply, his/her application launches a
file transfer session that will handle file
transmission. As soon as the session is
launched, the file transfer system attempts to
establish a connection with the other party’s
application, using the connection details that
are encapsulated within the acceptance reply.
This process is called the “start-up
connection”.
4.2.4.2.
Get File Details
Prior transmitting any file and followed by the
“start-up connection” task, the sender’s
application requires the user to specify the
file that he/she wishes to transfer.
Figure 4.33: Select file screen.
|
//initialise a
file dialog
FileDialog fd =
new
FileDialog(this,
"Select File",
FileDialog.LOAD);
fd.show();
//load file
dialog
dir =
fd.getDirectory();
//get file
directory
file =
fd.getFile();
//get
file name
filename = dir +
file; |
Figure 4.34: Specifying a file to
be transmitted.
4.2.4.3.
File Compression
Once the file details are known, the sender’s
application attempts to compress the file
preparing for transmission. This process is
implemented using the “Java zip utility
package”.
|
//create a file output stream
FileOutputStream dest = new
FileOutputStream(file + ".zip");
//create a zip output stream to
write to the zip file
ZipOutputStream out = new
ZipOutputStream(new
BufferedOutputStream(dest));
File f = new File(filename);
//create a new zip file
FileInputStream fi = new
FileInputStream(f); //create a
file input stream to read from file
ZipEntry entry = new
ZipEntry(filename);
//initialise a zip entry of the file
name
out.putNextEntry(entry);
//add the zip entry to the new zip
file
byte data[] = new
byte[2048];
//create an array of bytes of size
2048
//create a buffered input stream to
read from the original file in the
form of bytes
BufferedInputStream origin = new
BufferedInputStream(fi, 2048);
int size =
origin.available();
int count;
int progress = 0;
//read from original file if the end
of the file has not been reached
while((count = origin.read(data, 0,
2048)) != -1) {
out.write(data, 0,
count);
//write read bytes into the zip file
progress = progress +
count;
//calculate progress
bar.updateProgress(progress
/ size * 100); //update progress
bar
}//close while
origin.close();
//close original file
out.close();
//close
zip output stream |
Figure 4.35: File compression
process.
Figure 4.36: File transfer
session – compressing file.
<< Page
1
2
3
4
5
6
>> |