Beruflich Dokumente
Kultur Dokumente
by
G E L R Naga Prasad
New Delhi
PROFORMA OF PROJECT PROPOSAL
(Note: All entries of the proforma of suggestions should be filled in with appropriate and complete
information. Incomplete proforma of suggestions in any respect will be summarily rejected.)
E-mail: prasad_g22@yahoo.co.in
S/o G N Prabhuji,
Medipally, R R Dist-500039.
Programming Language: Java is used to create the project. We have used the server socket-
programming feature, which enables the Client/Server Architecture ability.
Front-end development: The front end is proposed to be developed on Java platform using
the netbeans IDE 5_5_1 as the Java Native Client. We are proposing to design the Front end as Applet
and the Server is also designed the same way. The communication between the server and the client
follows the TCP/IP protocol.
Back-end development: We have proposed to have the back end on the local drive in case of
clients. Since if a client when desires to save the data, then he could save the data log in the Html
Format into his/her local machine. On the other hand the sever could keep the track of all the
transactions that are made between the clients. Hence the server could also keep the log file saved in
the HTML format.
Please see that we are not incorporating the Auto save log feature of the Chat Client.
@A T1 cable Lan Network for deploying the server and the Client
@ JDK 1.6 version to be installed in the system, because the Jar Files would not nun if the following
version is not installed
@ All the systems must have configuration at least above P3 configurations. So that the speed of the
application would remain intact.
Date: Date:
************************************************************************
This is to certify that the project report entitled “Online Chat Client” submitted to Indira Gandhi
National Open University in partial fulfilment of the requirement for the award of the degree of
Master of Computer Applications (MCA) is an original work carried out by G E L R Naga Prasad
Enrolment No. 072257657 under my guidance. The matter embodied in this project is authentic and
is genuine work done by the student and has not been submitted whether to this University or to any
other University/ Institute for the fulfilment of the requirement of any course of study.
……………….. ………………………………….
Student Counsellor
G E L R Naga Prasad
S/o G N Prabhuji,
Medipally, R R Dist-500039.
3. Rajini ………………………………………….
* Students may take up roles such as Team Coordinator, Auditor/Receiver, Data Manager, Quality
Manager or others according to the needs of the project
ABSTRACT
Group Communication
Introduction to Networking
A Network is simply a collection of computers or other hardware devices that are connected together,
either physically or logically, using special hardware and software, to allow them to exchange
information and cooperate. Networking is the term that describes the processes involved in designing,
implementing, upgrading, managing and otherwise working with networks and network technologies.
Computer networks differ in their design. The two types of high-level network design are called
client-server and peer-to-peer. Client-server networks feature centralized server computers that store
email, Web pages, files and or applications. On a peer-to-peer network, conversely, all computers tend
to support the same functions.
The following characteristics are also used to categorize different types of networks:
• Protocol: The protocol defines a common set of rules and signals that computers on the
network use to communicate. Popular protocols for LANs are Ethernet, token-ring network.
• Geographic area: Local area networks (LANs), Metro Area Networks (MANs), Wide area
networks (WANs), reach across.
Instant Messaging
Instant messaging (IM) is a form of online communication that allows real-time (or close to real-time)
interaction through personal computers or mobile computing devices. Users can exchange messages
privately, similar to e-mail, or join group conversations. Although typed text remains the primary
convention for IM, the technology has grown significantly from early versions and now allows users
to send images, audio and video files, and other attachments. Early versions of IM appeared in the late
1990s, and the list of IM tools has grown to include dozens of applications. Technologies that enable
IM—such as wireless connectivity and mobile devices—have become widespread, providing a
“critical mass” for IM to reach near ubiquity. At the same time, many vendors whose primary
business is something other than IM have added IM functionality to their products.
Nearly all-learning management systems have incorporated chat tools, ranging from the elegant and
sophisticated, which include icons, sounds, and pictures, to the rudimentary, which simply provide
text in boxes. The interactive nature of IM is closer to spoken conversation than written
correspondence, allowing users to communicate in a manner that e-mail does not. At the same time,
the technology facilitates the kind of on-screen interaction, with its perceptions of distance and safety.
Functionality ranges widely for IM applications, but typically users log in to a service with a screen
name or ID. Most IM applications notify users when others join or leave, and many allow users to
indicate their status, for example “away from desk” or “in a meeting.” Once logged in, users can send
messages to individuals or join IM sessions. Most IM windows include an area where messages are
displayed chronologically and a composition box where messages are typed. Composition boxes
usually allow basic formatting of text, and most let users add images, multimedia files, or other
attachments. When someone types an instant message, the chat client indicates that a message is being
composed.
Chat Server is a computer dedicated to providing the processing power to handle and maintain
chatting and it users.
Technical Specifications:
Programming Language: Java is used to create the project. We have used the server socket-
programming feature, which enables the Client/Server Architecture ability.
Front-end development: The front end is proposed to be developed on Java platform using
the netbeans IDE 5_5_1 as the Java Native Client. We are proposing to design the Front end as Applet
and the Server is also designed the same way. The communication between the server and the client
follows the TCP/IP protocol.
Back-end development: We have proposed to have the back end on the local drive in case
of clients. Since if a client when desires to save the data, then he could save the data log in the
Html Format into his/her local machine. On the other hand the sever could keep the track of all
the transactions that are made between the clients. Hence the server could also keep the log file
saved in the HTML format.
Please see that we are not incorporating the Auto save log feature of the Chat Client.
@A T1 cable Lan Network for deploying the server and the Client
@ JDK 1.6 version to be installed in the system, because the Jar Files would not nun if the following
version is not installed
@ All the systems must have configuration at least above P3 configurations, so that the speed of the
application would remain intact.
Connection Procedure:
We are planning to have a server with n number of nodes to attach to the system. The server will have
one of the server-programming running on it. Servelet would be a normal choice in this case.
The client attached to the node will also have the client side-programming running, which would be
running as an applet. Usage of Swing components would be a better choice since swings as we know
is a Light Weight Object.
The Client would request for an account from the Server with the help of the IP Address of the Server.
Before entering to this we will first run the Servelet on the server and associate it with a PORT. So
any client who is getting connected to the server would be required to give the Port as well as the IP
address of the server.
This should be one case by which we could connect the other case would be connecting through the
Computer Name. Since we know that when a system is connected into a network, it is associated with
a computer name and hence if any Server-Client interaction has to be made with that Client, the
computer name is used for it. In our case we could use the server name as the Computer Name to
connect to the server.
Communication Procedure:
We have used the TCP/IP protocol to leverage the communication between the nodes in the network.
Every node in a network is represented by a IP and the same is used to Communicate. The server is
bounced through a Port (a number rather) and the same port is used by the client to communicate. It
should be noted that only one client could communicate to multiple clients at one instance.
We are not having any encryption of data. So security of the data could be one threat to the project.
Encryption could be imbibed in the future releases.
Technically the server routes the data to the client by the node selection made by the client. This we
are planning to do with the help of Vector Selection.
The Log data could be saved by the client on their machine and the format would be in HTML file.
This could be accessed by the User for their future purpose.
Acknowledgement
I would like to acknowledge the contributions of the following groups and individuals to the
development of my Project:
Mr Suraj:
Mr. Suraj directed me to a wide range of resources on the web. He answered all of my questions as
well as asked me questions that helped me to narrow my search. Further, He helped me figure out
correct documentation for sources that did not fit the Research Guide examples. He gave me this help
during class time and after school. I also worked with my fellow colleagues at Oracle who helped me
locate primary sources and to carry out the project smoothly.
TABLE OF CONTENTS
S.No Description
CHAPTER: 1. INTRODUCTION (A Brief about the Project)
1.1 Background
1.2 Objectives
1.3.1. Purpose
1.3.2. Scope
CHAPTER: 7. CONCLUSIONS
7.1 Conclusion
2 PERT CHART 22
3 GANTT CHART 23
6 INTERACTION DIAGRAMS 32
7 DEPLOYMENT DIAGRAM 33
INTRODUCTION
1. Introduction
1.1. Background:
Amazon Technologies a private owned organization in the capital city of Andhra Pradesh, Hyderabad,
that in operation since 2005 works for managing all the anonymities to the citizens of Hyderabad.
The organization works for the following goals in brief:
1. Project Implementation
2. ERP Consultation
3. Project Customization
7. Talent Management
For the given set of works that the organization has to do it has to conduct regular meetings of
officials at the various levels with teleconferencing etc
Keeping in the mind the past glory and the success of the organization Kushboo’s administration
never would like to compromise to delay of the information or unsuccessful processing of any event,
which may rise during the build of any project.
Method Typically Followed by Organization
For all the communication purposes the organization typically follows the mode of communicating on
the paper and pen sending all the necessary documents through internal courier and making the last
movement reminders to all the officials over the telephones and E-Mails.
By the cost analysis the organization found that the overheads for following this path makes a lot of
avoidable expenses that could be easily cut down.
With these set of tasks to be performed Kushboo’s organization, hence have decided to develop a
system that can make the administration of the organization better.
1.2. Objectives:
To be one of the best in the market in providing quality and reliable services in meeting the
employees satisfaction through the maximum utilization of the resources to generate profitability for
future enhancements.
With the growing cost factor and the decrease of the flow of cash in the world’s economy, The
Company Management have decided to build an internal tool, so that it could be cost efficient and
would provide the benefit of licenses.
This could also directly save the environment as the consumption of the papers and pens should be
minimal after the implementation of the project.
1.3.1 Purpose:
Purpose of this project is to create a Chat Communicator which has a feature of deploying a
server, deploying a client, authorizing the client establishing a Client Server Communication using
TCP/IP Protocol, saving the chat logs.
1.3.2 Scope:
The Scope Includes:
• The server should maintain a log of the communication made between the various clients.
SURVEY OF TECHNOLOGIES
Technical Information
The TCP/IP model is a description frame work for computer network protocols created in the 1970s
by DARPA, an agency of the United States Department of Defence. It evolved from ARPANET,
which was the world's first wide area network and a predecessor of the Internet. The TCP/IP Model is
sometimes called the Internet Reference Model or the DoD Model.
The TCP/IP model, or Internet Protocol Suite, describes a set of general design guidelines and
implementations of specific networking protocols to enable computers to communicate over a
network. TCP/IP provides end-to-end connectivity specifying how data should be formatted,
addressed, transmitted, routed and received at the destination. Protocols exist for a variety of different
types of communication services between computers.
TCP/IP is generally described as having four abstraction layers (RFC 1122). This layer architecture is
often compared with the seven-layer OSI Reference Model formalized after the TCP/IP specifications.
The TCP/IP model and related protocols are maintained by the Internet Engineering Task Force
(IETF).
3. Network layer
4. Transport Layer
5. Session Layer
6. Presentation layer
7. Application layer
Physical layer:
The Physical Layer is the first and lowest layer in the seven-layer OSI model of computer networking.
The Physical Layer comprises the basic hardware transmission technologies of a network. It is a
fundamental layer underlying the logical data structures of the higher level functions in a network.
The Physical Layer defines the means of transmitting raw bits rather than logical data packets over a
physical link connecting network nodes. The bit stream may be grouped into code words or symbols
and converted to a physical signal that is transmitted over a hardware transmission medium. The
Physical Layer provides an electrical, mechanical, and procedural interface to the transmission
medium
The Data Link Layer provides the functional and procedural means to transfer data between network
entities and might provide the means to detect and possibly correct errors that may occur in the
Physical Layer. Examples of data link protocols are Ethernet for local area networks (multi-node), the
Point-to-Point Protocol (PPP), HDLC and ADCCP for point-to-point (dual-node) connections.
Network Layer:
The Network Layer is Layer 3 of the seven-layer OSI model of computer networking. The Network
Layer is responsible for end-to-end (source to destination) packet delivery including routing through
intermediate hosts, whereas the Data Link Layer is responsible for node-to-node (hop-to-hop) frame
delivery on the same link.
The Network Layer provides the functional and procedural means of transferring variable length data
sequences from a source to a destination host via one or more networks while maintaining the quality
of service and error control functions.
Transport Layer:
In computer networking, the Transport Layer is a group of methods and protocols within a layered
architecture of network components within which it is responsible for encapsulating application data
blocks into data units (datagram, segments) suitable for transfer to the network infrastructure for
transmission to the destination host, or managing the reverse transaction by abstracting network
datagram and delivering their payload to an application. Thus the protocols of the Transport Layer
establish a direct, virtual host-to-host communications transport medium for applications and
therefore also referred to as transport protocols.
Session Layer:
The Session Layer is Layer 5 of the seven-layer OSI model of computer networking. The Session
Layer provides the mechanism for opening, closing and managing a session between end-user
application processes, i.e. a semi-permanent dialogue. Communication sessions consist of requests
and responses that occur between applications. Session Layer services are commonly used in
application environments that make use of remote procedure calls (RPCs).
Presentation Layer:
The Presentation Layer is Layer 6 of the seven-layer OSI model of computer networking. The
Presentation Layer is responsible for the delivery and formatting of information to the application
layer for further processing or display. It relieves the application layer of concern regarding
syntactical differences in data representation within the end-user systems. Note: An example of a
presentation service would be the conversion of an EBCDIC-coded text file to an ASCII-coded file.
Application Layer:
Application Layer is a term used in categorizing protocols and methods in architectural models of
computer networking. Both the OSI model and the Internet Protocol Suite (TCP/IP) contain an
application layer.In TCP/IP, the Application Layer contains all protocols and methods that fall into
the realm of process-to-process communications via an Internet Protocol (IP) network using the
Transport Layer protocols to establish underlying host-to-host connections.
TCP/IP
Architectural Model
2.2 UDP Protocol:
The User Datagram Protocol (UDP) is one of the core members of the Internet Protocol Suite, the set
of network protocols used for the Internet. With UDP, computer applications can send messages, in
this case referred to as datagram, to other hosts on an Internet Protocol (IP) network without requiring
prior communications to set up special transmission channels or data paths. UDP is sometimes called
the Universal Datagram Protocol. The protocol was designed by David P. Reed in 1980 and formally
defined in RFC 768.
UDP uses a simple transmission model without implicit hand-shaking dialogues for guaranteeing
reliability, ordering, or data integrity. Thus, UDP provides an unreliable service and datagram may
arrive out of order, appear duplicated, or go missing without notice. UDP assumes that error checking
and correction is either not necessary or performed in the application, avoiding the overhead of such
processing at the network interface level. Time-sensitive applications often use UDP because
dropping packets is preferable to using delayed packets. If error correction facilities are needed at the
network interface level, an application may use the Transmission Control Protocol (TCP) or Stream
Control Transmission Protocol (SCTP) which are designed for this purpose.
UDP's stateless nature is also useful for servers that answer small queries from huge numbers of
clients. Unlike TCP, UDP is compatible with packet broadcast (sending to all on local network) and
multicasting (send to all subscribers).
Common network applications that use UDP include: the Domain Name System (DNS), streaming
media applications such as IPTV, Voice over IP (VoIP), Trivial File Transfer Protocol (TFTP) and
many online games.
An application is a program that can execute from any operating system prompt. Standalone
applications can either be windows-based applications or console applications. Windows-based
applications can have a graphical user interface. They use features that are supported by platforms like
Microsoft, Macintosh, Motif, and OS/2. Console applications are the character based application that
do not have a graphical user interface. A stand alone application uses the resources of a single
computer. Network applications can access objects that execute across many computers over a
network. Distributed applications can access objects that execute across many computers on a
network.
Applications are allowed to read from and write to the files on the local computer. Applications
establish network connections, access resources across a network, and launch applications over a
network.
A stand-alone application resides on the HDD of a local machine. When the application needs to be
executed, it is fetched from the HDD into the memory and executed.
The J2EE platform supports a simplified, component-based development model. Because it is based
on the Java programming language and the Java 2 Platform, Standard Edition (J2SE platform), this
tm
• Supports division of labor--Components help divides the labor of application development among
specific skill sets, enabling each member of a development team to focus on his or her ability. Web
page authors can create JSP templates, Java programming language coders can implement
application behaviour, domain experts can develop business logic, and application developers and
integrators can assemble and deploy applications. This division of labor also expedites application
maintenance. For example, the user interface is the most dynamic part of many applications,
particularly on the Web. With the J2EE platform, Web page authors can tweak the look and feel of
JSP pages without programmer intervention.
2.5 Project Management Stylus:
Defining project success before you start requires critical and conceptual thinking. A project can be
conceived as a measured chain of achievements and this chain is created by starting at the end of the
project. This last achievement in a project is what defines the success of the project. This
measurement is not just a deliverable and a due date; it is instead a strategic result that needs to be
defined with clear consultation with the stakeholders. Let's talk about what project management is
all about.
Initiation and Definition Phase: The problem is identified, available solutions are studied, potential
solutions determined and a project brief is created in this stage. A decision is made to outsource or
work on the project internally. As may be the case, the service provider and the team members are
then identified. The project scope defines the vision and the end-results of the project. A needs
analysis document will gather detail information like target audience, technology profiling, budget
and schedule, staffing and risks. A project scope or proposal document is then developed as a detailed
proposal for meeting project needs. team to work on the project. A project plan is then developed. It
Team Management: The project leader/manager aims to create an atmosphere of a cooperative and
effective team culture. Team management includes all the processes that are needed to identify and
secure an effective project team. Determining where the requisite staff can be obtained and then
identifying the roles and responsibilities of each team member, how they communicate with each
other and build the necessary rapport, undergo training if necessary, resolve conflicts and monitor
performance levels are necessary to ensure the effectiveness of the team.
Communication Management: Effective communication in a project between all the stakeholders and
the project team is imperative as it ensures that the stakeholders gain and maintain a clear
understanding of the status of project's progress. This could either be a weekly report on the status, on
the risks involved, the schedule and the budget status and can be in a documented format or handed
out or reported in a meeting. At Stylus, we hold information meetings every Monday where all the
projects are reported about and explained. This also ensures that the entire organization is aware of all
that happens on the projects and project-related activities within the organization.
Risk Management: The project plan usually contains a risk plan that describes strategies and methods
used to identify and avoid risks throughout the life cycle of the project. All kinds of risks are
identified here - business risks that are associated with the nature of the work done or the client and
the target environment, risks within the project and the team environment and finally technical risks
involved with the system or other aspects of the technology of the application.
Configuration Management: In any project, many versions and files are created during the project
and thus increasing the number of versions and components of the product. It is important to identify
and track these versions and document how any changes made to these documents will be handled
and reported. All project documentation; project hardware and software and project outputs are placed
under project management.
Quality Management: Evaluation and testing activities contribute to how the final deliverable in a
project adheres to relevant standards. Quality of a package or deliverable doesn't mean checking it at
the end and ensuring that it is bug free. It also means quality is tracked right through the project. A
quality management plan is developed at the beginning of the project and a quality check
representative is assigned to a project at the beginning of the project.
Project Time Management: Developing procedures to manage activities and the schedule of a project
involve giving a detailed schedule at the project definition stage. A work breakdown structure is
developed based on the proposal in the project scope document and agreed to in the project contract.
Cost Management: To ensure that the costs are maintained during the project, the project manager
with the help of the client requirements capture team proposes the budget and the resources involved
in the project at the beginning when the scope of the project is defined. These budgets and schedules
are reviewed at regular intervals, especially when deliverables are iteratively defined in a project.
• A discussion of how you think this solution will actually work to solve the problem.
3. System will allow saving the log (chat). In other words the chat history could be saved on the
client system on the basis of the request raised by him.
4. The server will have the authorization to disconnect any client at any point of time.
5. System will generate popup message if the server chats with the client in the private mode.
Non requirements
1. System do not support the auto save feature of the client message, hence the
messages have to be saved explicitly one the chat is done.
Program Evaluation Review Technique, PERT can be both a cost and a time
management system. PERT is organized by events and activities or tasks. PERT has several
advantages over bar charts and is likely to be used with more complex projects. One advantage of
PERT is that it is scheduling device that also shows graphically which tasks must be completed before
others are begun.
Also, by displaying the various task paths, PERT enables the calculation of a critical path.
Each path consists of combinations of tasks, which must be completed. PERT controls time and cost
during the project and also facilitates finding the right balance between completing a project on time
and completing it within the budget.
PERT CHART
31 MAR 15 APR 2009
2009
30 APR 2009
START I/O DESIGN
INTEGRATION
20 APR AND TESTING
2009
ANALYSIS
4 APR
2009
CODING FINISH
25 APR 2009
5 MAY 2009
WRITE
MANUAL 27 APR
2009
A Bar Chart is perhaps the simplest form of formal Library Management. The bar chart is also
known as Gantt chart. It is used almost exclusively for scheduling purposes and therefore controls
only the time of projects.
Gantt Charts are a project control technique that can be used for several purposes, including
scheduling, budgeting and resource planning. A Gantt chart is a Bar Chart, with each bar representing
an activity. The bars are drawn against a time line. The length of each bar is proportional to the length
of time planned for the activity.
The following steps describe the works that are carried out in the particular weeks.
The problem has been identified and is discussed with in the group and the problem definition
is developed.
The different types of software, hardware requirements and user requirements have been
identified and analyzed.
The interfaces have been designed manually and different modules are identified.
The user interface components (swings) concept in java has been studies and discussed.
The data flow diagrams for the interfaces designed were prepared.
The coding has been written to connect the database to the front end.
All the modules have been integrated and the integration testing performed on the system as a
whole.
The future enhancements have been made and the project is submitted with proper documentation
being evaluated by guide.
HDD : 40 GB or above
This section provides an overview of the Identification of requirement and objectives of the new
communication system and defines functions and operations of the application/system.
The initial phase involved gathering of requirements for the new application under development. At a
functional level, these can be summarized as
2. Provision of two or more users communicating with each other through the application,
multiple users can communicate through text messages.
4. The server must be ‘intelligent’ to provide IP based authentication and ability for one-to-one
communication between clients.
Thus to summarize, we can say the objectives of the new system are to:
Create a Chat Communicator which has a feature of deploying a server, deploying multiple clients,
authorizing the client to perform client-client and client-server networking and routing and lastly but
not the least saving the chat logs.
Now in the next section under this title, we attempt to describe the operational and functional aspects
in technical detail for our system.
We implement a Java based application because of features designed to enhance the process of
developing distributed applications, the J2EE platform offers several benefits such as Simplified
architecture, Freedom of choice in servers, tools, Ease of Integration, Scalability to meet demand
variations, Flexible security model etc.
On a micro level, the functionalities of the system were identified and implemented.
1. Chat server program listens for incoming calls from clients. Client running in any PC can
connect to the server if IP address of the server is known.
3. It broadcast the message from clients to all the clients connected to the server.
4. Chat client views the messages from all the clients and the server.
Our server will be a stand-alone program -- a single Java process running on its own machine. It won't
require any support software other than a Java virtual machine. And it won't require a Web server or
application server, although a Web server or application server will likely be used to serve the client
applet to the client. Our communications between client and server will pass through a Java object
called a Socket, called TCP/IP sockets. Sockets are not at all Java-specific; the term is taken directly
from the terminology of general IP (Internet Protocol) network programming.
All clients have to connect themselves to the server. The server should listen for client connection.
To interpret data flow, data should be encoded in a language understandable by the server and the
client. By using the same language for the client and the server, the sender is sure that his data sent are
well processed by the receiver. For example, a client can send an instruction (to the server) to transmit
some data to another.
The DFD is designed to show how a system is divided into smaller portions and to highlight the flow
of data between those parts. Data-flow diagrams (DFDs) are one of the three essential perspectives of
the structured-systems analysis and design method. With a data-flow diagram, users are able to
visualize how the system will operate, what the system will accomplish, and how the system will be
implemented. Developing a data-flow diagram helps in identifying the transaction data in the data
model.
DFD approach:
1. The system designer makes "a context level DFD" or Level 0, which shows the "interaction" (data
flows) between "the system" (represented by one process) and "the system environment" (represented
by terminators).
2. The system is "decomposed in lower-level DFD (Level 1)" into a set of "processes, data stores, and
the data flows between these processes and data stores".
3. Each process is then decomposed into an "even-lower-level diagram containing its sub processes".
4. This approach "then continues on the subsequent sub processes", until a necessary and sufficient
level of detail is reached which is called the primitive process.
DFD is also a virtually designable diagram that technically or diagrammatically describes the inflow
and outflow of data or information that is provided by the external entity
This level shows the overall context of the system and its operating environment and shows the whole
system as just one process.
This level is a decomposition of a process shown in a level-1 diagram, as such there should be a level-
2 diagram for each and every process shown in a level-1 diagram.
SYSTEM DESIGN
4.1 Basic Modules
First step is to identifying all the features that needs to be implemented in the software. The
requirements are a good guide in identifying the features. According to the requirements specification,
we need to develop the following features in the system.
The chat application has to have feature of a server, clients able to connect to it, server able to
accept/reject clients, client-client communication once both are allowed by server, broadcasting by
server to all the active clients on the network. Finally, there needs to be a memory space to store all
the messages in the log. This saving has to be done at the client system and also auto-save is not an
option in our system.
UML forms one of the most essential tools effectively used by almost all the software development
organizations. The model’s which remains outcome of UML guides the coders through rest of the
software development task. It has been estimated that behind every successful software product, 50%
of the share is taken away by expect human visualization and the models drawn out of it. Hence,
UML is not just drawing sketches; it is a notion to drop down the complex software systems to its
lowest levels using human oriented languages.
Actors hold a significant role in every human interactive application. In our application the probable
actors can be
- User/client
- Server
Login
Client 1 Client 2
Permission
Chat
When closing of
application by client,
option to save chat on
Save Chat
Permission Granted
Permission Granted
Client 1 request for permission to chat with Client 2 and once granted , can chat with client 2
Server can Broadcast the message to all the clients on the Server
Client 3
Client 1 Client 2
Logs to Save
Server the Chat
Following is a template for the RS document. Some example requirements are entered in to it to show
how to use the template. This would help in validating the system during testing.
RS1 The client should Essential Client asks for The server’s IP, port details
enable login to permission by are known to all clients on
network contacting server the network
on and providing it
IP, port details
RS2 The server must Essential The server verifies The discarded client cannot
accept or discard the the details access the network to
client provided by client communicate with other
and process them clients
to accept/reject
client
RS3 Client-client chat Essential A client provides Main functionality of our
must be enabled details of other application
client it wants to
chat with to the
server which will
grant access
Java is one of the first programming languages to consider security as part of its design. The Java
language, compiler, interpreter, and runtime environment were each developed with security in mind.
The compiler, interpreter, and Java-compatible browsers all contain several levels of security
measures that are designed to reduce the risk of security compromise, loss of data and program
integrity, and damage to system users.
Java is portable, multithreaded, architecture neutral and robust thus making it a preferable language
for our application.
import java.net.UnknownHostException;
import javax.swing.JDialog;
import javax.swing.JFrame;
import org.jouvieje.network.ClientConnection;
import org.jouvieje.network.ServerConnection;
import org.jouvieje.network.Chat.*;
import org.jouvieje.network.Chat.protocol.ChatServerLink;
JDialog.setDefaultLookAndFeelDecorated(true);
JFrame.setDefaultLookAndFeelDecorated(true);
if(args.length == 0)
{
new IntroFrame().setVisible(true);
else if(args.length == 1)
try
server = new
ServerConnection<ChatServerLink>(Integer.parseInt(args[0]));
catch(NumberFormatException e)
System.out.println("/tChatMain <CommunicationPort>");
System.exit(1);
new Server(server).setVisible(true);
else if(args.length == 3)
InetAddress IP = null;
try
IP = InetAddress.getByName(args[1]);
catch(UnknownHostException e)
{
e.printStackTrace();
System.exit(1);
try
catch(NumberFormatException e1)
System.exit(1);
----------------------------------------------------------------------------------------------------------------
About me.Java
package org.jouvieje.tools;
import java.awt.*;
import java.awt.event.*;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import org.jouvieje.network.HtmlViewer.HtmlViewerDialog;
super();
this.animated = animated;
this.info = infoApp;
if(help != null)
this.yOffset = help.length*13;
else
this.yOffset = OFFSET_WITHOUT_HELP;
this.help = toHelpText(help);
initialize();
super(owner, modal);
this.animated = animated;
this.info = infoApp;
if(help != null)
this.yOffset = help.length*13;
else
this.yOffset = OFFSET_WITHOUT_HELP;
this.help = toHelpText(help);
initialize();
super(owner, modal);
this.animated = animated;
this.info = infoApp;
if(help != null)
this.yOffset = help.length*13;
else
this.yOffset = OFFSET_WITHOUT_HELP;
this.help = toHelpText(help);
initialize();
this.setContentPane(getJContentPane());
this.setSize(352, 349+yOffset);
this.setTitle("About Me");
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
if(jContentPane == null)
jContentPane.setLayout(null);
jContentPane.setBackground(Color.black);
jContentPane.setForeground(Color.yellow);
jContentPane.add(getJPicture(), null);
jContentPane.add(getJInfo(), null);
jContentPane.add(getJAuteur(), null);
jContentPane.add(getJEmail(), null);
jContentPane.add(getJSite(), null);
jContentPane.add(getJSite1(), null);
jContentPane.add(getJSite2(), null);
jContentPane.add(getJHelp(), null);
return jContentPane;
if(jPicture == null)
jPicture.setHorizontalAlignment(SwingConstants.LEFT);
if(animated)
jPicture.setIcon(new
ImageIcon(getClass().getResource("/Data/Picture/Auteur.gif")));
else
jPicture.setIcon(new
ImageIcon(getClass().getResource("/Data/Picture/Auteur.jpg")));
return jPicture;
if(jInfo == null)
jInfo.setHorizontalAlignment(SwingConstants.CENTER);
jInfo.setText(info);
return jInfo;
if(jAuteur == null)
jAuteur.setHorizontalAlignment(SwingConstants.CENTER);
jAuteur.setText("Author : Jouvieje");
return jAuteur;
if(jEmail == null)
return jEmail;
if(jSite == null)
jSite.setBackground(Color.black);
jSite.setForeground(Color.yellow);
jSite.setHorizontalAlignment(SwingConstants.CENTER);
return jSite;
if(jSite1 == null)
jSite1.setText("<html><font color=\"#639ACE\"><a
href=\"http://manish.mitra.fr/\">http://manish.mitra.fr/</a></font></html>");
jSite1.setForeground(Color.yellow);
jSite1.setHorizontalAlignment(SwingConstants.LEFT);
jSite1.setCursor(new Cursor(Cursor.HAND_CURSOR));
jSite1.addMouseListener(new MouseAdapter() {
if(link == null) {
try {
catch(MalformedURLException e) {
e.printStackTrace();
return link;
openURL(getLink(), urlAsString);
});
return jSite1;
if(jSite2 == null)
{
jSite2.setBackground(Color.black);
jSite2.setForeground(Color.yellow);
jSite2.setHorizontalAlignment(SwingConstants.LEFT);
jSite2.setCursor(new Cursor(Cursor.HAND_CURSOR));
jSite2.addMouseListener(new MouseAdapter() {
String urlAsString =
"http://google.co.uk/~mamitra/manish/manish/index.php";
if(link == null) {
try {
catch(MalformedURLException e) {
e.printStackTrace();
return link;
openURL(getLink(), urlAsString);
});
}
return jSite2;
if(jHelp == null)
gridBagConstraints1.fill = GridBagConstraints.BOTH;
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.weightx = 1.0D;
gridBagConstraints1.weighty = 1.0D;
jHelp.setLayout(new GridBagLayout());
TitledBorder ivjTitledBorder =
BorderFactory.createTitledBorder(null , "Menu d\'aide" ,
TitledBorder.DEFAULT_JUSTIFICATION , TitledBorder.DEFAULT_POSITION , new
Font("Dialog", Font.BOLD, 13) , Color.yellow);
ivjTitledBorder.setTitle("Help Menu");
jHelp.setBorder(ivjTitledBorder);
jHelp.add(getJHelpLabel(), gridBagConstraints1);
return jHelp;
if(jHelpLabel == null)
jHelpLabel.setText(help);
jHelpLabel.setVerticalAlignment(SwingConstants.TOP);
return jHelpLabel;
if(helps == null)
return "";
String s = "<html><body>";
s += helps[i]+"<br>";
s += "</body></html>";
return s;
/**
* @param link
*/
private void openURL(URL link, String urlAsString)
Client Connection.java
package org.jouvieje.network;
import java.io.*;
import java.net.*;
/**
*/
protected ClientConnection()
this.hostIP = null;
this.hostPort = -1;
}
/**
*/
this.hostIP = hostIP;
this.hostPort = hostPort;
/**
* Open the connection to the server and creates a socket to communicates with him.
*/
try
/*
*/
return socket.isConnected();
catch(IOException e)
{
e.printStackTrace();
return false;
/**
*/
return socket;
/**
*/
if(!isConnected())
return true;
try
if(getSocket() != null)
getSocket().close();
catch(IOException e)
{
e.printStackTrace();
return !isConnected();
/**
*/
if(getSocket() != null)
return false;
/**
* Send datas
*/
out.write(data);
out.flush();
return data.length();
}
/**
* Send datas
*/
out.write(data, 0, data.length);
out.flush();
return data.length;
/**
*/
/**
* Send datas
*/
public int send(InputStream is, int buffSize) throws IOException
int sent = 0;
while(is.available() > 0)
out.write(datas, 0, readed);
sent += readed;
out.flush();
return sent;
/**
* Send datas
*/
int sent = 0;
while(is.available() > 0)
out.write(buffer, 0, readed);
sent += readed;
out.flush();
return sent;
/**
*/
if(getSocket() == null)
return -1;
try
return getSocket().getInputStream().available();
catch(IOException e)
return -1;
/**
*/
{
if(getSocket() == null)
new IOException();
InputStream in = getSocket().getInputStream();
if(in.available() > 0)
input = input_;
return input;
return null;
if(getProtocol() == null)
return;
if(getSocket() != null)
InputStream in = getSocket().getInputStream();
if(in.available() > 0)
{
//There is some problem synchronizing in few case when using
JOptionPane (blocking) ...
synchronized(getProtocol())
getProtocol().processInput(in);
/**
*/
return protocol;
/**
*/
this.protocol = protocol;
/**
* @return your IP
*/
public InetAddress getLocalIP()
if(getSocket() != null)
return getSocket().getLocalAddress();
return null;
/**
*/
if(isConnected())
return getSocket().getInetAddress();
return hostIP;
/**
*/
if(getSocket() != null)
return getSocket().getLocalPort();
return -1;
/**
* @return the communication port of the server
*/
if(getSocket() != null)
return getSocket().getPort();
return hostPort;
/**
*/
return false;
Connectable.java
package org.jouvieje.network;
import java.net.InetAddress;
/**
*/
/**
* @return -1 on failure
*/
public boolean connect();
/**
*/
/**
*/
/**
*/
public E getSocket();
/**
*/
/**
*/
*/
/**
*/
/**
*/
}\
Protocol.java
package org.jouvieje.network;
import java.io.InputStream;
/**
*/
Server Connection.java
package org.jouvieje.network;
import java.io.*;
import java.net.*;
import java.util.Vector;
/**
*/
/**
*/
{
this.port = port;
/**
*/
try
/*
* Creates a ServerSocket
*/
return true;
catch(Exception e)
e.printStackTrace();
serverSocket = null;
return false;
/**
* Listen on the port for a client connection request.<BR>
*/
public E acceptConnection()
try
//Accept a client
return addLink(socket);
catch(IOException e)
return null;
/**
*/
return serverSocket;
if(serverSocket != null)
{
serverSocket.close();
serverSocket = null;
/**
*/
if(getServerLinkCreator() == null)
E client = null;
try
catch(Exception e)
e.printStackTrace();
client = null;
return null;
}
/**
*/
return clients;
/**
* @return the link with the client in the index of the list.
* @deprecated
*/
synchronized(clients)
return clients.get(index);
return null;
/**
*/
return clients.size();
}
/**
*/
if(link.disconnect())
return clients.remove(link);
return false;
/**
*/
synchronized(clients)
getLink(i).disconnect();
//Remove all client links from the list and create a new empty one
clients.clear();
/**
*/
if(!isConnected())
return true;
disconnectAllLink();
try
//Close server
closeServerSocket();
return true;
catch(Exception e)
e.printStackTrace();
serverSocket = null;
return false;
}
/**
*/
if(serverSocket != null)
return !serverSocket.isClosed();
return false;
/**
*/
return serverLinkCreator;
/**
*/
this.serverLinkCreator = linkCreator;
}
/**
* @return null
*/
return null;
/**
*/
if(isConnected())
return getSocket().getInetAddress();
return null;
/**
* @return -1
*/
return -1;
/**
*/
if(getSocket() != null)
return getSocket().getLocalPort();
return port;
/**
*/
return true;
Serverlink.Java
package org.jouvieje.network;
import java.io.IOException;
import java.net.Socket;
/**
*/
/**
*/
this.socket = socket;
/**
*/
return true;
/**
*/
return true;
}
ServerLinkCreator.java
package org.jouvieje.network;
import java.io.IOException;
import java.net.Socket;
ChatFrame.java
package org.jouvieje.network.Chat;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import org.jouvieje.network.Chat.protocol.ProtocolEnums;
import org.jouvieje.network.parser.html.HtmlString;
import org.jouvieje.tools.AboutMeDialog;
/**
* Defines the common part of the client and the server frame.<BR>
*/
this.user = user;
this.pseudo = pseudo;
if(jContentPane == null)
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJPanelTop(), BorderLayout.NORTH);
jContentPane.add(getJSplit(), BorderLayout.CENTER);
jContentPane.add(getJButtonConnect(), BorderLayout.SOUTH);
initializeEnd();
attachEvents();
}
return jContentPane;
if(jPanelTop == null)
jPanelTop.setLayout(new BorderLayout());
jPanelTop.add(getJInfoL(), BorderLayout.NORTH);
jPanelTop.add(getJPeusoL(), BorderLayout.WEST);
jPanelTop.add(getJPseudos(), BorderLayout.CENTER);
return jPanelTop;
if(jInfoL == null)
return jInfoL;
if(jPeusoL == null)
return jPeusoL;
if(jPseudos == null)
jPseudos.setEnabled(false);
jPseudos.addActionListener(new ActionListener() {
refreshInfo();
});
return jPseudos;
if(jSplit == null)
jSplit.setOneTouchExpandable(true);
jSplit.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
jSplit.setLeftComponent(getJPanelSend());
jSplit.setRightComponent(getJPanelReceive());
jSplit.setDividerSize(8);
jSplit.setDividerLocation(getSize().width/2);
jSplit.setResizeWeight(0.5);
return jSplit;
if(jPanelSend == null)
jPanelSend.setLayout(new BorderLayout());
jPanelSend.add(getJInfoSend(), BorderLayout.NORTH);
jPanelSend.add(getJScrollSend(), BorderLayout.CENTER);
jPanelSend.add(getJPanelSendButtons(), BorderLayout.SOUTH);
return jPanelSend;
if(jInfoSend == null)
jInfoSend.setHorizontalAlignment(SwingConstants.CENTER);
return jInfoSend;
if(jScrollSend == null)
{
jScrollSend.setViewportView(getJTextSend());
return jScrollSend;
if(jTextSend == null)
return jTextSend;
if(jPanelSendButtons == null)
jPanelSendButtons.setLayout(new BorderLayout());
jPanelSendButtons.add(getJButtonSend(), BorderLayout.CENTER);
return jPanelSendButtons;
if(jButtonSend == null)
{
jButtonSend = new JButton();
jButtonSend.setText("Send");
jButtonSend.setEnabled(false);
return jButtonSend;
if(jPanelReceive == null)
jPanelReceive.setLayout(new BorderLayout());
jPanelReceive.add(getJInfoReceive(), BorderLayout.NORTH);
jPanelReceive.add(getJScrollReceive(), BorderLayout.CENTER);
jPanelReceive.add(getJPanelButtonsReceived(),
java.awt.BorderLayout.SOUTH);
return jPanelReceive;
if(jInfoReceive == null)
jInfoReceive.setHorizontalAlignment(SwingConstants.CENTER);
return jInfoReceive;
}
protected JScrollPane getJScrollReceive()
if(jScrollReceive == null)
return jScrollReceive;
if(jTextReceive == null)
jTextReceive.setDocument(new HTMLDocument());
jTextReceive.setEditorKit(new HTMLEditorKit());
jTextReceive.setText(new HtmlString().getHtmlCode());
jTextReceive.setEditable(false);
return jTextReceive;
if(jPanelButtonsReceived == null)
jPanelButtonsReceived.setLayout(new BorderLayout());
jPanelButtonsReceived.add(getJButtonClear(),
BorderLayout.CENTER);
jPanelButtonsReceived.add(getJButtonSave(),
java.awt.BorderLayout.EAST);
return jPanelButtonsReceived;
if(jButtonClear == null)
jButtonClear.setText("Clear messages");
jButtonClear.addActionListener(new ActionListener() {
getJTextReceive().setText(new
HtmlString().getHtmlCode());
});
return jButtonClear;
if(jButtonSave == null)
jButtonSave.setText("Save history");
jButtonSave.addActionListener(new ActionListener() {
int choice =
getJFileSaver().showSaveDialog(ChatFrame.this);
if(choice == JFileChooser.APPROVE_OPTION)
try
BufferedWriter br = new
BufferedWriter(new FileWriter(file));
"E-mail : <A
HREF=\"mailto:manish.mitra@oracle.com\">manish.mitra@oracle.com</A><BR>"+
"Site : <A
HREF=\"http://google.co.uk/~mamitra/\">http://google.co.uk/~mamitra/</A><BR>"+
" &n
bsp; "+
"<A
HREF=\"http://manish.mitra.fr/\">http://manish.mitra.fr/</A></P>";
html.insert(bottomPage);
br.write(html.getHtmlCode());
br.close();
catch(IOException e1)
return;
}
});
return jButtonSave;
if(jFileSaver == null)
jFileSaver.setMultiSelectionEnabled(false);
jFileSaver.setFileFilter(new FileFilter() {
return f.getName().toLowerCase().endsWith("html") ||
f.getName().toLowerCase().endsWith("htm") ||
f.isDirectory();
});
}
return jFileSaver;
if(jButtonConnect == null)
return jButtonConnect;
if(jJMenuBar == null)
jJMenuBar.add(getJMenuActions());
jJMenuBar.add(getJMenuAbout());
return jJMenuBar;
if(jMenuAbout == null)
jMenuAbout.setText("?");
jMenuAbout.add(getJMenuAboutDialog());
}
return jMenuAbout;
if(jMenuAboutDialog == null)
jMenuAboutDialog.setText("About me");
jMenuAboutDialog.addActionListener(new ActionListener() {
});
return jMenuAboutDialog;
/**
*/
protected void print(String message)
text.insert(message+"<HR>");
getJTextReceive().setText(text.getHtmlCode());
/**
*/
if(DEBUG_MODE)
System.out.println("DEBUG : "+s);
Client.Java
package org.jouvieje.network.Chat;
import java.awt.event.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.*;
import org.jouvieje.network.*;
import org.jouvieje.network.parser.html.HtmlString;
import static org.jouvieje.network.Chat.protocol.Decoder.*;
super(user, pseudo);
user.setProtocol(getProtocol());
initialize();
this.setJMenuBar(getJJMenuBar());
this.setSize(500, 350);
this.setContentPane(getJContentPane());
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(true);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
if(user.isConnected())
disconnectClient(false);
});
getJInfoSend().setText("Message to send");
getJInfoReceive().setText("Message Received");
refreshInfo();
getJButtonSend().addActionListener(new ActionListener() {
String to = (String)getJPseudos().getSelectedItem();
if(message != null)
message =
HtmlString.toHtmlString(message).getBody();
});
getJButtonConnect().addActionListener(new ActionListener() {
getJButtonConnect().setEnabled(false);
if(user.connect())
getListener().start();
refreshInfo();
getJButtonConnect().setEnabled(false);
getJMenuDisconnect().setEnabled(true);
else
JOptionPane.showMessageDialog(Client.this,
"<HTML>Server may not be ready.<BR>Try to connect at another time.</HTML>");
getJButtonConnect().setEnabled(true);
getJMenuDisconnect().setEnabled(false);
});
}
/**
*/
if(user.isConnected())
if(getJPseudos().getItemCount() == 1)
else
info += " You are the only user connected on the Chat
server !";
else
info = "<HTML>"+info+"<BR> </HTML>";
getJInfoL().setText(info);
if(jMenuActions == null)
{
jMenuActions = new JMenu();
jMenuActions.setText("Actions");
jMenuActions.add(getJMenuDisconnect());
return jMenuActions;
if(jMenuDisconnect == null)
jMenuDisconnect.setText("Disconnect");
jMenuDisconnect.setEnabled(false);
jMenuDisconnect.addActionListener(new ActionListener() {
disconnectClient(false);
});
return jMenuDisconnect;
/*******************************************/
/**
*/
protected Thread getListener()
if(listener == null)
while(!end)
try
//Equivalent to : if(user.hasInput()
user.getProtocol.processInput(...);
user.checkInput();
catch(IOException e)
end = true;
try
Thread.sleep(20);
catch(InterruptedException e){}
}
user.disconnect();
};
return listener;
/**
* This method decodes input message and execute what things should be done.
*/
//Read inputs
try
while(in.available() > 0)
catch(IOException e)
return;
datas = datas.trim();
//Process inputs
switch(tagValue.tag)
case REQUEST:
if(Request.valueOf(tagValue.value) ==
Request.PSEUDO)
printDebug("Your pseudo is
requested");
send(encodeTag(Tag.PSEUDO,
pseudo));
else if(Request.valueOf(tagValue.value)
== Request.DISCONNECTION)
disconnectClient(true);
break;
case MESSAGE:
printInput(from, message);
break;
case PSEUDO_LIST:
while(tokens.hasMoreTokens())
String newPseudo =
tokens.nextToken().replace(pseudoSeparatorCode, pseudoSeparator);
if(!newPseudo.equals(pseudo))
pseudos.add(newPseudo);
refreshPseudos(pseudos);
break;
case INFO:
JOptionPane.showMessageDialog(Client.this,
"<HTML>"+tagValue.value+"</HTML>");
break;
};
}
/**
*/
try
catch(IOException e)
printDebug("Send fails");
return false;
/*******************************************/
/**
*/
/**
*/
if(sended)
" : </B></U><BR>"+message+"</I></P>");
else
/**
*/
getJPseudos().setModel(new DefaultComboBoxModel(pseudos));
//Refresh informations
refreshInfo();
}
/**
*/
if(!serverInformed)
send(encodeRequest(Request.DISCONNECTION));
//Close connection
user.disconnect();
listener = null;
refreshPseudos(new Vector());
getJButtonConnect().setEnabled(true);
getJMenuDisconnect().setEnabled(false);
IntroFrame.java
package org.jouvieje.network.Chat;
import javax.swing.JFrame;
/**
*/
public IntroFrame()
super();
initialize();
this.setSize(295, 200);
this.setContentPane(getJContentPane());
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
}
private javax.swing.JPanel getJContentPane()
if (jContentPane == null)
jContentPane.setLayout(null);
jContentPane.add(getJLabelTitle());
jContentPane.add(getJLabelInfo());
jContentPane.add(getJLabelQuestion());
jContentPane.add(getJButtonServer());
jContentPane.add(getJButtonClient());
return jContentPane;
if(jLabelTitle == null)
jLabelTitle.setVerticalAlignment(javax.swing.SwingConstants.TOP);
jLabelTitle.setHorizontalAlignment
(javax.swing.SwingConstants.CENTER);
14));
}
return jLabelTitle;
if(jLabelInfo == null)
jLabelInfo.setText("<HTML><BODY>Author : Manish
Mitra<BR><BR>E-Mail :
<A HREF=\"manish.bvc@gmail.com\">manish.bvc@gmail.com</A>");
jLabelInfo.setVerticalAlignment(javax.swing.SwingConstants.TOP);
jLabelInfo.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
return jLabelInfo;
if(jLabelQuestion == null)
return jLabelQuestion;
if(jButtonServer == null)
jButtonServer.setText("The Server");
jButtonServer.addActionListener(new java.awt.event.ActionListener()
{
new SettingsFrame(true).setVisible(true);
IntroFrame.this.dispose();
});
return jButtonServer;
if(jButtonClient == null)
jButtonClient.setText("The Client");
jButtonClient.addActionListener(new java.awt.event.ActionListener()
{
new SettingsFrame(false).setVisible(true);
IntroFrame.this.dispose();
}
});
return jButtonClient;
Ippanel.Java
package org.jouvieje.network.Chat;
import java.awt.Component;
import java.awt.Container;
import java.awt.FocusTraversalPolicy;
import java.awt.event.FocusEvent;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
*/
* Used to know which component should be focus when tab key is pressed.
* (setNextFocusableComponent is deprecated)
*/
if(focusCycleRoot.equals(getJIp1()))
return getJIp2();
else if(focusCycleRoot.equals(getJIp2()))
return getJIp3();
else if(focusCycleRoot.equals(getJIp3()))
return getJIp4();
else if(focusCycleRoot.equals(getJIp4()))
return getJIp1();
return null;
if(focusCycleRoot.equals(getJIp1()))
return getJIp4();
else if(focusCycleRoot.equals(getJIp2()))
return getJIp1();
else if(focusCycleRoot.equals(getJIp3()))
return getJIp2();
else if(focusCycleRoot.equals(getJIp4()))
return getJIp3();
return null;
return getFirstComponent(focusCycleRoot);
return getJIp1();
return getJIp4();
};
/**
* Default constructor
*/
public IpPanel()
super();
initialize();
/**
* @return void
*/
private void initialize()
this.setSize(144, 22);
this.setPreferredSize(new java.awt.Dimension(144,22));
this.setLayout(null);
this.add(getJIp1(), null);
this.add(getJIpSeparator12(), null);
this.add(getJIp2(), null);
this.add(getJIpSeparator23(), null);
this.add(getJIp3(), null);
this.add(getJIpSeparator34(), null);
this.add(getJIp4(), null);
/**
* @return javax.swing.JTextField
*/
if(jIp1 == null)
jIp1.setFocusTraversalPolicy(nextFocus);
jIp1.setSize(30, 22);
jIp1.setLocation(0, 0);
jIp1.addKeyListener(new java.awt.event.KeyAdapter() {
IpPanel.this.keyReleased(e);
}
});
jIp1.addFocusListener(new java.awt.event.FocusListener() {
IpPanel.this.focusLost(e);
IpPanel.this.focusGained(e);
});
return jIp1;
/**
* @return javax.swing.JLabel
*/
if(jIpSeparator12 == null)
jIpSeparator12.setSize(8, 22);
jIpSeparator12.setText(".");
jIpSeparator12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jIpSeparator12.setLocation(30, 0);
return jIpSeparator12;
}
/**
* @return javax.swing.JTextField
*/
if(jIp2 == null)
jIp2.setFocusTraversalPolicy(nextFocus);;
jIp2.setSize(30, 22);
jIp2.setLocation(38, 0);
jIp2.addKeyListener(new java.awt.event.KeyAdapter() {
IpPanel.this.keyReleased(e);
});
jIp2.addFocusListener(new java.awt.event.FocusListener() {
IpPanel.this.focusLost(e);
IpPanel.this.focusGained(e);
});
return jIp2;
}
/**
* @return javax.swing.JLabel
*/
if(jIpSeparator23 == null)
jIpSeparator23.setSize(8, 22);
jIpSeparator23.setText(".");
jIpSeparator23.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jIpSeparator23.setLocation(68, 0);
return jIpSeparator23;
/**
* @return javax.swing.JTextField
*/
if(jIp3 == null)
jIp3.setFocusTraversalPolicy(nextFocus);;
jIp3.setSize(30, 22);
jIp3.setLocation(76, 0);
jIp3.addKeyListener(new java.awt.event.KeyAdapter() {
IpPanel.this.keyReleased(e);
});
jIp3.addFocusListener(new java.awt.event.FocusListener() {
IpPanel.this.focusLost(e);
IpPanel.this.focusGained(e);
});
return jIp3;
/**
* @return javax.swing.JLabel
*/
if(jIpSeparator34 == null)
jIpSeparator34.setSize(8, 22);
jIpSeparator34.setText(".");
jIpSeparator34.setLocation(106, 0);
jIpSeparator34.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
return jIpSeparator34;
/**
* @return javax.swing.JTextField
*/
if(jIp4 == null)
jIp4.setSize(30, 22);
jIp4.setLocation(114, 0);
jIp4.setFocusTraversalPolicy(nextFocus);
jIp4.addKeyListener(new java.awt.event.KeyAdapter() {
IpPanel.this.keyReleased(e);
});
jIp4.addFocusListener(new java.awt.event.FocusListener() {
IpPanel.this.focusLost(e);
});
return jIp4;
if(((JTextField)e.getComponent()).getText().length() >= 3)
((JTextField)e.getComponent()).transferFocus();
verifyInput(((JTextField)e.getComponent()), true);
else
verifyInput(((JTextField)e.getComponent()), false);
verifyInput((JTextField)e.getComponent(), true);
}
}
/**
*/
try
return dns1+"."+dns2+"."+dns3+"."+dns4;
catch(NumberFormatException e)
return null;
/**
*/
{
super.setEnabled(enabled);
getJIp1().setEnabled(enabled);
getJIp2().setEnabled(enabled);
getJIp3().setEnabled(enabled);
getJIp4().setEnabled(enabled);
/**
*/
try
if(modify)
jtf.setText("255");
else
jtf.setText(""+value);
catch(Exception e)
jtf.setText("");
}
Server.Java
package org.jouvieje.network.Chat;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.util.Vector;
import javax.swing.*;
import org.jouvieje.network.*;
import org.jouvieje.network.Chat.protocol.ChatServerLink;
import org.jouvieje.network.parser.html.HtmlString;
super(user, SERVER_PSEUDO);
user.setServerLinkCreator(new ServerLinkCreator<ChatServerLink>() {
attachListener(clientLink);
attachProtocol(clientLink);
return clientLink;
});
initialize();
this.setSize(500, 350);
this.setContentPane(getJContentPane());
this.setJMenuBar(getJJMenuBar());
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(true);
this.addWindowListener(new WindowAdapter() {
if(user.isConnected())
disconnect(false);
});
getJPanelSendButtons().add(getJButtonSendAll(), BorderLayout.EAST);
getJInfoSend().setText("Info to send");
getJInfoReceive().setText("Message transmitted");
refreshInfo();
getJButtonSend().addActionListener(new ActionListener() {
ChatServerLink client =
getClientLink((String)getJPseudos().getSelectedItem());
String info = getJTextSend().getText();
String infoFormatted =
HtmlString.toHtmlString(info).getBody();
});
getJButtonConnect().addActionListener(new ActionListener() {
getJButtonConnect().setEnabled(false);
if(user.connect())
getAcceptClientsThread().start();
refreshInfo();
getJMenuCloseServer().setEnabled(true);
else
JOptionPane.showMessageDialog(Server.this,
"<HTML>Fails to open the server !<BR>Please restart the application.</HTML>");
getJButtonConnect().setEnabled(true);
});
if(user.isConnected())
if(user.getLinkCount() >= 1)
else
ChatServerLink client =
getClientLink((String)getJPseudos().getSelectedItem());
if(client.isAuthentified())
else
}
else
info = "<HTML>"+info+"<BR> </HTML>";
getJInfoL().setText(info);
if(jButtonSendAll == null)
jButtonSendAll.setText("Send All");
jButtonSendAll.setEnabled(false);
jButtonSendAll.addActionListener(new ActionListener() {
if(info != null)
String infoFormatted =
HtmlString.toHtmlString(info).getBody();
infoFormatted = encodeTag(Tag.INFO,
infoFormatted);
sendAll(infoFormatted);
printInfo("<B>"+ALL_USERS+"</B>", info,
true);
});
}
return jButtonSendAll;
if(jMenuActions == null)
jMenuActions.setText("Actions");
jMenuActions.add(getJCheckAcceptAllClients());
jMenuActions.addSeparator();
jMenuActions.add(getJMenuDisconnectClient());
jMenuActions.add(getJMenuDisconnectAllClients());
jMenuActions.addSeparator();
jMenuActions.add(getJMenuCloseServer());
return jMenuActions;
if(jCheckAcceptAllClients == null)
jCheckAcceptAllClients.setSelected(false);
return jCheckAcceptAllClients;
if(jMenuDisconnectClient == null)
jMenuDisconnectClient.setText("Disconnect a client");
jMenuDisconnectClient.setEnabled(false);
jMenuDisconnectClient.addActionListener(new ActionListener() {
if(getJPseudos().getSelectedIndex() >= 0)
ChatServerLink client =
getClientLink((String)getJPseudos().getSelectedItem());
disconnectClient(client, false);
printDisconnect(client.getPseudo());
});
return jMenuDisconnectClient;
if(jMenuDisconnectAllClients == null)
jMenuDisconnectAllClients.setEnabled(false);
jMenuDisconnectAllClients.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(getJPseudos().getSelectedIndex() >= 0)
disconnectAllClient();
});
return jMenuDisconnectAllClients;
if(jMenuCloseServer == null)
jMenuCloseServer.setText("Close server");
jMenuCloseServer.setEnabled(false);
jMenuCloseServer.addActionListener(new ActionListener() {
disconnect(true);
});
return jMenuCloseServer;
/*******************************************/
/**
* When a user is connected, the server can choose if the client is accepted.
*/
if(acceptClientsThread == null)
while(user.isConnected())
/*
*/
String pseudoRequest =
encodeRequest(Request.PSEUDO);
printDebug("Requesting pseudo");
send(client, pseudoRequest);
String tempPseudo =
TEMP_PSEUDO+user.getLinkCount();
client.setPseudo(tempPseudo);
getJPseudos().addItem(tempPseudo);
client.getListener().start();
};
return acceptClientsThread;
/**
*/
client.setListener(new Thread() {
while(!end)
try
//Equivalent to : if(user.hasInput()
user.getProtocol.processInput(...);
client.checkInput();
}
catch(IOException e)
end = true;
try
Thread.sleep(20);
catch(InterruptedException e){}
user.disconnectLink(client);
});
/**
*/
clientLink.setProtocol(new Protocol() {
/**
* This method decodes input message and execute what things should
be done.
*/
public void processInput(InputStream in)
//Read inputs
try
while(in.available() > 0)
catch(IOException e)
return;
datas = datas.trim();
if(client.isAuthentified())
switch(tagValue.tag)
case REQUEST:
if(Request.valueOf(tagValue.value) == Request.DISCONNECTION)
disconnectClient(client,
true);
printDisconnect(client.getPseudo());
JOptionPane.showMessageDialog(Server.this, client.getPseudo()+" is
disconnected !");
break;
case MESSAGE:
String sender =
decodeField(Field.FROM, datas);
String to =
decodeField(Field.TO, datas);
String message =
decodeField(Field.BODY, datas);
ChatServerLink receiver =
getClientLink(to);
if(receiver != null)
sended = send(receiver,
encodeMessage(sender, to, message));
if(sended)
printMessage(sender, to,
message, sended);
{
//Inform that the receiver
is not found
String info =
encodeTag(Tag.INFO, "<HTML>Addressee ("+to+") of this message does not exists
:<BR>"+message+"</HTML>");
sended = send(client,
info);
printInfo(sender, info,
sended);
break;
else
if(tagValue.tag == Tag.PSEUDO)
printDebug("Receiving identification :
"+clientPseudo);
if(!isPseudoValide(clientPseudo))
if(getJCheckAcceptAllClients().isSelected())
accepted = true;
else
{
/*
* if the used is
registered ... But, for this tutorial, I let the server doing this job.
*/
int choice =
JOptionPane.showConfirmDialog(Server.this, "<html>New user identified :
"+clientPseudo+"<br>Do you want to accept him ?</html>", "New user",
JOptionPane.YES_NO_OPTION);
accepted = (choice ==
JOptionPane.YES_OPTION);
if(accepted)
client.setPseudo(clientPseudo);
client.setAuthentified(true);
sendPseudoList();
else
disconnectClient(client,
false);
}
}
else
String info =
encodeTag(Tag.INFO, "<HTML>Your pseudo is invalide (already exists or contains the
sequence "+
printInfo(client.getPseudo(), info,
sended);
//Eject it !
disconnectClient(client, false);
else
printInfo(client.getPseudo(), info,
sended);
//Send a request for the client pseudo
String pseudoRequest =
encodeRequest(Request.PSEUDO);
printDebug("Requesting pseudo");
send(client, pseudoRequest);
});
/**
* @param datas
*/
try
catch(IOException e)
return false;
}
}
/**
*/
if(client.isAuthentified())
send(client, datas);
/*******************************************/
/**
* @param to receiver
*/
if(sended)
print("<P STYLE=\"background-color:#CCCCCC\"><I><U><B>Info
sended to "+to+" : </B></U><BR>"+info+"</I></P>");
else
print("<P STYLE=\"background-
color:#CCCCCC\"><I><U><B><FONT COLOR=red>Fail to send info to "+to+" :
</FONT></B></U><BR>"+info+"</I></P>");
}
/**
* @param to receiver
*/
private void printMessage(String from, String to, String message, boolean sended)
if(sended)
" : </B></U><BR>"+message+"</I></P>");
else
" : </FONT></B></U><BR>"+message+"</I></P>");
/**
* @param to a client
*/
print("<P STYLE=\"background-color:#FF6666\"><I><U><B>"+to+" is
disconnected</B></U><BR></I></P>");
}
/**
*/
vector.add(client.getPseudo());
if(client.isAuthentified())
if(!first)
pseudoList += pseudoSeparator;
pseudoList += client.getPseudo().replace(pseudoSeparator,
pseudoSeparatorCode);
first = false;
//Update gui
getJPseudos().setModel(new DefaultComboBoxModel(vector));
refreshInfo();
if(!first)
sendAll(encodeTag(Tag.PSEUDO_LIST, pseudoList));
}
getJButtonSend().setEnabled(enable);
getJButtonSendAll().setEnabled(enable);
getJMenuDisconnectClient().setEnabled(enable);
getJMenuDisconnectAllClients().setEnabled(enable);
getJPseudos().setEnabled(enable);
/**
*/
if(pseudo.indexOf(pseudoSeparatorCode) != -1)
return false;
/**
*/
return client;
return null;
/**
*/
if(!clientInformed)
send(client, encodeRequest(Request.DISCONNECTION));
user.disconnectLink(client);
sendPseudoList();
/**
*/
sendAll(encodeRequest(Request.DISCONNECTION));
user.disconnectAllLink();
//Reset gui
getJPseudos().setModel(new DefaultComboBoxModel());
printDisconnect(ALL_USERS);
/**
*/
if(ask)
if(choice == JOptionPane.NO_OPTION)
return;
sendAll(encodeRequest(Request.DISCONNECTION));
//Close connection
user.disconnect();
acceptClientsThread = null;
getJPseudos().setModel(new DefaultComboBoxModel());
enableComponents(false);
getJButtonConnect().setEnabled(true);
getJMenuCloseServer().setEnabled(false);
refreshInfo();
ChatServerLink.java
package org.jouvieje.network.Chat.protocol;
import java.io.IOException;
import java.net.Socket;
import org.jouvieje.network.ServerLink;
super(socket);
/**
*/
return pseudo;
/**
*/
this.pseudo = pseudo;
/**
*/
return listener;
/**
this.listener = thread;
/**
*/
return authentified;
/**
*/
this.authentified = identified;
Decoder.java
package org.jouvieje.network.Chat.protocol;
import java.util.Vector;
/**
int begin = 0;
int i, j, k;
i = datas.indexOf("<", begin);
j = datas.indexOf(">", i+1);
if(i == -1 || j == -1)
k = datas.indexOf("</"+query+">", j);
if(k == -1)
//Adding tag
begin = k+query.toString().length()+3;
}
return vector;
return null;
Encoder.java
package org.jouvieje.network.Chat.protocol;
/**
*/
return null;
return "<"+tag+">"+value+"</"+tag+">";
{
if(request == null)
return null;
return "<"+Tag.REQUEST+">"+request+"</"+Tag.REQUEST+">";
return Encoder.encodeTag(Tag.MESSAGE,
fromField+toField+messageField);
return null;
return "<"+field+">"+value+"</"+field+">";
ProtocolEnums.java
package org.jouvieje.network.Chat.protocol;
REQUEST,
MESSAGE,
PSEUDO,
PSEUDO_LIST,
INFO;
PSEUDO,
DISCONNECTION;
//Message fields
FROM,
TO,
BODY;
this.tag = query;
this.value = value;
HtmlViewerDialog.java
package org.jouvieje.network.HtmlViewer;
import java.awt.Dialog;
import java.awt.Frame;
import java.net.URL;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
}
public HtmlViewerDialog(Frame frame, boolean modal, URL url)
super(frame, modal);
page = url;
initialize();
super(dialog, modal);
page = url;
initialize();
this.setSize(500, 400);
this.setResizable(true);
this.setLocationRelativeTo(null);
this.setContentPane(getJContentPane());
{
if(jContentPane == null) {
jContentPane.setLayout(new java.awt.BorderLayout());
jContentPane.add(getJEditorPane(),
java.awt.BorderLayout.CENTER);
return jContentPane;
if(jEditorPane == null)
jEditorPane.setDocument(new HTMLDocument());
jEditorPane.setEditorKit(new HTMLEditorKit());
try
jEditorPane.setPage(page);
catch(Exception e)
:<BR>"+page.toString()+"</BODY></HTML>");
return jEditorPane;
}
}
HtmlString.java
package org.jouvieje.network.parser.html;
/**
*/
/**
*/
public HtmlString()
htmlCode = BLANK_PAGE;
/**
*/
this.htmlCode = htmlCode;
return getHtmlCode();
/**
*/
if(htmlCode == null)
htmlCode = BLANK_PAGE;
return htmlCode;
/**
*/
{
int index = getHtmlCode().indexOf("<BODY>");
return index+6;
return index;
/**
*/
/*
*/
if(text == null)
return null;
/**
*/
htmlString.insert(newText);
return htmlString;
Errors are relevant only after the system is in use. A system that has been put to use with out testing
can be disastrous in terns of the application. The importance of software testing and its implications
cannot be overemphasized. Software testing is a critical element of Software Quality Assurance and
represents the ultimate review of the specifications, design and coding.
Testing Objectives
The main objective of testing is to uncover a host of errors, systematically and with minimum effort
and time. Stating formally, we can say,
But there is one thing that testing cannot do (just to quote a very famous sentence) “Testing cannot
show the absence of defects, it can only show that software defects are presents.”
As the test results are gathered and evaluated they begin to give a qualitative indication of the
reliability of the software. If severe errors are detected, the overall quality of the software is a natural
suspect. If, on the other hand, all the errors, which are encountered, are easily modifiable, then one of
the two conclusions can be made:
• The tests are inadequate to detect possibly present errors.
• The software more or less confirms to the quality and reliable standards.
Levels of Testing
In order to uncover the errors present in different phases we have the concept of levels of
testing. The basic levels of testing are
Unit testing focuses verification effort on the smallest unit of software i.e. the module. Using
the detailed design and the process specifications testing is done to uncover errors within the
boundary of the module. All modules must be successful in the unit test before the start of the
integration testing begins.
Each module has been tested by giving different sets of inputs (giving wrong ID and
password etc) when developing the module as well as finishing the development so That each
module works without any error. The inputs are validated when accepting from the user.
When we connect to the server after choosing “The Server” from the Login
Window
Once the server is established .Here the port is chosen to be as 1024
Here the client gives the login details of the server and gets connected to it.
The server gets a notification about the client and the server authenticates the
client.
This output shows the client status window after the client is connected to the
server.
Here the window shows Chat Communication between the Clients. The message
log in server is also displayed.
The Server sends the data to the clients and the same is shown as pooped up
window in the clients interface.
We could also save the chat log for the future reference,
This window is displayed when the client is disconnected from the server.
This window is displayed when the server is disconnected or killed
abruptly.
The Saved chat log in document. the saved document is in the HTML format.
CONCLUSIONS
7.1 Conclusion:
We have thus successfully implemented a Chat application as part of a Group Communications
application design under Networking. The application will enable easy communication between users
in an enterprise and at the same time, enable quick and fast access and cheaper communication media.
With more enhancements beyond the scope of this project, we can scale up the application to suit the
communication needs of a modern organization in a better way.
2. WikiPedia