Chat Server
Chat Server
CHAT SERVER
Submitted to:
I hereby declared that the work presented in the dissertation titled “Chat Server” in
partial fulfillment of requirement for the award of degree of Masters of
Computer Application submitted in KIET SCHOOL OF COMPUTER APPLICATION ,
KRISHNA INSTITUTE OF ENGINEERING & TECHNOLOGY, GHAZIABAD, is
authentic record of my work carried out during the period from 15th Feb,2006
to 28th Apr,2006.
With immense pleasure, I take this opportunity to express my sincere thanks and deep
gratitude to all those people who extended their wholehearted co-operation and their help for
me in completing this project successfully.
I express my humble to Mr. Amit Gupta and Miss. Nimisha goel, for his valuable
guidance and inspiration in my taking up this project. I think that with out him, I couldn’t
complete my project.
I am personally very thankful to Mr. Parshant Aggarwal and Miss. Sangeeta Arora for
providing me the information about java and help me in the development of Chat Server.
At last but not the least I give my hearty thanks to my family members and well wishers
who supported me morally and encouragement constructive criticism given to me during the
project period.
( Tarun Kumar)
Part 1:
Introduction
Hardware and Software used
Part 2:
Part 3:
History of JAVA
Remote Method Invocation (RMI)
Part 4:
Database Used
Part 5:
Screen Shots
Part 6:
Coding
Part 7:
Progress Table
Conclusion
Bibliography
Part 1
Introduction
INTRODUCTION
The SDLC includes ten phases during which defined IT work products are created or
modified. The tenth phase occurs when the system is disposed of and the task
performed is either eliminated or transferred to other system. The tasks and work
products for each phase are described in subsequent chapters. Not every project will
require that phases be sequentially executed. However, the phases are interdependent.
Depending upon the size and complexity of the project, phases may be combined or
may overlap.
• Identify and assign the roles and responsibilities of all involved parties, including
functional and technical managers, throughout the system development life cycle.
The system Development Life Cycle methodology will help to achieve these goals
by:
Initiation phase
The initiation of a system (or project) begins when a business need or opportunity is
identified. A project Manager should be appointed to manage the project. This business
need is documented in a Concept Proposal. After the Concept Proposal is approved,
the System Concept Development phase begins.
System Concept Development Phase
Once a business need is approved, the approaches for accomplishing the concept are
reviewed for feasibility and appropriateness. The System Boundary Document identifies
the scope of the system and requires Senior Official approval and funding before
beginning the Planning Phase.
Planning Phase
The concept is further developed to describe how the business will operate once the
approved system is implemented, and to assess how the system will impact employee
and customer privacy. To ensure the products and / or services provide the required
capability on-time and within budget, projects resources, activities, schedules, tools and
reviews are defined. Additionally, security certification and accreditation activities begin
with the identification of system security requirements and the completion of a high level
vulnerability assessment.
Functional user requirements are formally defined and delineate the requirements in
terms of data, system performance, security, and maintainability requirements for the
system. All requirements are defined to a level of detail sufficient for system design to
proceed. All requirements need to be measurable and testable and to the business
need or opportunity identified in the Initiation Phase.
Design Phase
The physical characteristics of the system are designed during this phase. The
operating environment is established, major subsystems and their inputs and outputs
are defined, and processes are allocated to resources. Everything requiring user input
or approval must be documented and reviewed by the user. The physical characteristics
of the system are specified and a detailed design is prepared. Subsystems identified
during design are used to create a detailed structure of the system. Each subsystem is
partitioned into one or more design units or modules. Detailed logic specification is
prepared for each software module.
Development phase
The detailed specifications produced during the design phase are translated into
hardware, communications, and executable software. Software shall be unit tested,
integrated, and retested in a systematic manner. Hardware is assembled and tested.
The various components of the system are integrated and systematically tested. The
user tests the system to ensure that the functional requirements, as defined in the
functional requirements documents, are satisfied by the developed or modified system.
Prior to installing and operating the system in a production environment, the system
must undergo certification and accreditation activities.
Implementation Phase
The system or system modifications are installed and made operational in a production
environment. The phase is initiated after the system has been tested and accepted by
the user. This phase continues until the system is operating in operating in production in
accordance within the defined user requirement.
The system operation is ongoing. The system is monitored for continued performance
in accordance with user requirements, and needed system modifications are
incorporated. The operational system is periodically assessed through In-Process
Reviews to determine how the system can be made more efficient and effective.
Operations continue as long as the system can be effectively adapted to respond to an
organization’s needs. When modifications or changes are identified as necessary, the
system may reenter the planning phase.
Disposition Phase
The disposition activities ensure the orderly termination of the system and preserve the
vital information about the system so that some or all of the information may be
reactivated in the future if necessary. Particular emphasis is given to proper
preservation of the data processed by the system, so that the data is effectively
migrated to another system or archived in accordance with applicable records
management regulations and policies, for potential future access.
INITIATION PHASE:
OBJECTIVE
CONCEPTUAL PROPOSAL
OBJECTIVE
System Concept Development begins when the Conceptual Proposal has been formally
approved and requires study and analysis that may lead to System development
activities.
The review and approval of the Concept Proposal begins the formal studies and
analysis of the need in the System Concept Development Phase and begins the life
cycle of an identifiable project.
The following activities are performed as part of the System Concept Development
Phase. The results of these activities are captured in four phase documents and their
underlying institutional processes and procedures (See Figure).
PLANNING PHASE:
OBJECTIVE
Many of the plans essential to the success of the entire project are create in this phase;
the created plans are then reviewed and update throughout the remaining SDLC
phases.
In the planning phase, the concept is further developed to describe how the business
will
Operate once the approved system is implemented and to assess how the system will
impact employee and customer privacy. To ensure the products and/or services
provides the required capability on-time and within budget, project resources, activities,
schedules,
Tools, and reviews are defined. Additionally, security certification and accreditation
activities begin with identification of system security requirements and the completion of
a high-level vulnerability assessment.
TASK AND ACTIVITIES
The following tasks are performed as part of the planning phase. The results of these
activities are captured in various project plans and solicitation documents.
REQUIREMENT ANALYSIS :
OBJECTIVE
The Requirement Analysis Phase will begin when the previous phase documentation
has been approved or by management direction. Documentation related to user
requirement from the planning phase shell be used as the basis for further user needs
analysis and the
Development of detailed user requirements. The analysis may reveal new insights into
the Overall information system requirements, and, in such instances, all deliverables
should be revised to reflect this analysis. During the Requirement Analysis phase, the
system shall be defined in ore detail with regard to system inputs, processes, outputs,
and interfaces. This definition process occurs At the function level .The system shall be
described in terms of the function to be performed, not in terms of computer programs,
files, and data streams. The emphasis in this phase is on determining what function
must be performed rather than how to perform those functions.
The following tasks are performed during the Requirements Analysis Phase. The tasks
and activities actually performed depend on the nature of the project , Inclusion of tasks
for the ,Alternative SDLC work patterns.
First consolidate and affirm the business needs. Analyze the intended use of the system
And specify the functional and data requirements. Connect the functional requirements
to the data requirements. Defines functional and system requirements that are not easily
Expressed in data and process models Refine the high level architecture and logical
design to support the system and functional requirement.
A logical model is constructed that describes the fundamental processes and data
needed to support the desired business functionality. This logical model will show how
processes interact and how processes created and use data. These processes will be
derived from the activity descriptions provided in the System Boundary Document.
Functions and entity types contained in the logical model are extended and refine from
those provided in the Concept Development Phase. End-user and business areas
experts will evaluate all identified processes and data structures to ensure accuracy,
logical consistency, and completeness. An analysis of business activities and data
structure perform to produce entity-relationship diagrams, process hierarchy diagrams,
process dependency diagrams, and associated documentation. An interaction analysis
produce Process logic and action diagrams, definitions of the business algorithms, entity
life-cycle diagrams, and entity state change matrices .A detailed analysis of the current
technical architecture, application software, and data is conducted to ensure that
limitation or
Unique requirements have not been overlooked.
Include all possible requirements including those for:
• Functional and capability specifications, including performance, physical
characteristics, and environmental conditions under which the software item is to
perform;
• Interfaces external to the software item;
• Safety specification, including those related to methods of operation and
maintenance, environment influences, and personnel injury;
• Security specification, including those related to compromise of sensitive
information;
• Human-factors engineering, including those related to manual operations,
human- equipment interactions, constraints on personnel, and areas needed
concentrated human attention, that are sensitive to human errors and training;
DESIGN PHASE:
OBJECTIVE
The objective of the Design Phase is to transform the detailed, defined requirements
into complete, detailed specifications for the system to guide the work of the
Development Phase. The decisions made in this phase address, in detailed, how the
system will meet the defined functional, physical, interface, and data requirements.
Design Phase activities may be conducted in an iterative fashion, producing first a
general system design that emphasizes the functional features of the system, then a
more detailed system design that expands the general design by providing all the
technical detailed.
The following tasks are performed during the Design Phase. The tasks and activities
actually performed depend on the nature of the project. Guidelines for selection and
inclusion of tasks for the Design Phase may be found, Alternate SDLC Work Patterns.
DEVELOPMENT PHASE:
OBJECTIVE
The objective of the development phase will be to convert the deliverables of the design
phase into a complete information system. Although much of the activity in the
development phase addresses the computer programs that make up the system, this
phase also puts in place the hardware, software, and communications environment for
the system and other important elements of the overall systems.
The activities of this phase translate the system design produced in the design phase
into a working information system capable of addressing the information system
requirements. The development phase contains activities for building the system, testing
the system, and conducting functional qualification testing, to ensure the system
functional processes satisfy the functional process requirements in the Functional
Requirement Document (FRD)
At the end of this phase, the system will be ready for the activities of the Integration and
Testing Phase.
Integration the software units, components and modules. Integration the software units
and software components and test in accordance with the integration plan. Ensure that
A module satisfies the requirements of the software at the conclusion of the integration
activity.
Conducting qualification testing in accordance with the qualification requirement for the
software items. Ensure that the implementation of each software requirement is tested
for compliance. Support audit(s), which could be conducted to ensure that:
The results of the audits shall be documented. If both hardware and software are under
development of integration, the audits may be postponed until the System Qualification
Testing. Upon successful completion of the audits, if conducted, update and prepare the
deliverable software product for System Integration, System Qualification Testing,
Hardware Installation, or Software Acceptance Supports as applicable. Also, establish a
baseline for the design and code of the software item.
• Integrate System
Integrate the software configuration items with hardware configuration items, manual
operations, and other systems as necessary, into the system. The aggregates shall be
tested, as they are developed, against their requirements. The integration and the test
results shall be documented. For each qualification requirement of the system, a set of
tests, test cases (inputs, outputs, test criteria), and test procedure for conducting
System Qualification Testing shall be developed and documented. Ensure that the
integration system is ready for System Qualification Testing.
• Install Software
Install the software product in the target environment as designed and in accordance
with the Installation Plan. The resources and information necessary to install the
software product shall be determined and be available. The developer shall assist the
acquirer with the set-up activities. Where the installed software product is replacing an
existing system, the developer shall support any parallel running activities that are
required. Ensure that
the software code and databases initialize ,execute, and terminate as specified in the
contract. The installation events and results shall be documented.
Acceptable review and testing shall consider the results of the Joint Reviews, Audits,
Software Qualification Testing, and System Qualification Testing (if performed). The
results of the acceptance review and testing shall be documented.
The developer shall complete and deliver the software product as specified. The
developer
Shall provide initial and continuing training and support to the acquirer as specified.
OBJECTIVE
The objective of this phase is to prove the developed system that the developed system
satisfies the requirements defined in the FRD. Several types of tests will be conducted
in the phase. First, Subsystem integration tests shall be executed and evaluate by the
development team to prove that the program components integrate properly into the
subsystems and that the subsystems integrate properly into a application. Next, the
testing team conducts and evaluates system tests to ensure the developed system
meets all technical requirements, including performance requirement. Next, the testing
team and the security program manager conduct security tests to validate that the
access and data security requirements are met. Finally, users participate in acceptance
testing to confirm that the developed system meets all user requirements as stated in
the FRD. Acceptance testing shall be done in a simulated “real” user environment with
the users using simulating or real target platforms and infrastructures .
The tasks and activities actually performed depend on the nature of the project. The
following tasks should be completed during the integration and test phase .
Establish the various test teams and ensure the test system(s) are ready.
The test and evaluation team is responsible for creating/loading the test database(s)
and executing the integration test(s). This is to ensure that program components
integrate properly into the subsystems and the subsystem integrates properly into an
application.
The test and evaluation team is responsible for creating/loading the test database(s)
and executing the system tests. All results should be documented on the test analysis
report, test problem report and on the test analysis approval determination. Any field
components should be migrated back to the development phase for rework, and the
passed components should be migrated ahead for security testing.
The test and evaluation team will again create or load the test databases and execute
security (penetration) tests. All tests will be documented, similar to those above. Failed
components will be migrated back to the development phase for rework, and passed
components will migrate ahead for implementation.
During this phase, the systems technical lead or the developers will finalize the software
development document from the development phase. He/They will also finalize the
operations or systems administration manual, user manual, training plan maintenance
manual, conversion plan, implementation plan , contingency plan and update the
interface control document from the design phase. The project manager should finalize
the system security plan and the security risks assessment form the requirement
analysis phase and the project management plan from the planning phase. The
configuration manager should finalize the configuration management plan from the
planning phase. The quality assurance office/person should finalize the quality
assurance plan from the planning phase. And finally, the project manager should finalize
the cost benefit analysis and the risk management plan from the system concept
development phase.
IMPLEMENTATION PHASE
OBJECTIVE
In the phase, the system or system modification are installed and made operational in a
production environment. The phase is initiated after the system has been tested and
accepted by the user and project manager. Activities in the phase include notification of
implementation to end users, execution of the previously defined training plan, Data
Entry of Conversion, and post implementation review. This phase continues until the
system is operating in production in accordance with the defined user requirements.
The new system can fall into three categories, replacement of a manual process,
replacement of a legacy system, or upgrade to an existing system regardless of the
type of system, all expects of the implementation phase should be followed. This will
ensure the smoothest possible transition to the organization’s desired goal.
Task and activities in the implementation phase are associated with certain deliverables
described in section 10.3. The task and activities actually performed depend on the
nature of the project. A description of these tasks and activities is provided below.
The implementation notice should be sent to all users and organizations affected by the
implementation. Additionally, it is good policy to make internal organizations not directly
affected by the implementation aware of the schedule so that allowances can be made
for a disruption in the normal activities of the section. Some notification methods are E-
Mail,
Internal Memo to heads of department, Voice Tree Messages. The notice include:
More then half of the life cycle costs are attributed to the operations and maintenance of
systems .In this phase, it is essential that all facets of operations and maintenance are
performed. The system is being used and scrutinized to ensure that it meets the needs
initially stated in the planning phase. Problems are detected and new needs arise. This
may require modification to existing code, new code to be developed and/or hardware
configuration changes. Providing user support is an ongoing activity. New users will
require training and other will require training as well. The emphasis of this phase will be
to ensure that the users needs are met and the system continues to perform as
specified in the operational environment. Additionally, as operations and maintenance
personal monitor the current system they may become aware of better ways to improve
the system
And therefore make recommendations. Changes will be required to fix problems,
possibly add features and make improvements to the system. This phase will continue
as long as the system is in use.
o Ensure that systems and networks are running and available during the
defined hours and operations;
o Implement non emergence requests during scheduled outages, as
prescribed in the operations manual;
o Ensures all processes, manual and automated, are documented in the
operating procedures. These processes should comply with the system documentation;
o Acquisition and storage of supplies (i.e. paper, toner, taps, removable
disks);
o Performs backups (day-to-day protection, contingency);
o Perform the physical security functions including ensuring adequate
UPS, Personal have proper security clearances and proper access privileges etc;
o Ensure contingency planning for disaster recovery is current and tested;
o Ensure users are trained on current processes and new processes;
o Ensure that service level objectives are kept accurate and are
monitored;
o Maintain performance measurements, statistics, and system logs.
Examples of performance measures include volume and frequency of date to be
processed in each mode, order and type of operations;
o Monitor the performance statistics, report the results and escalate
problems when they occur.
Maintained data /Software Administration is needed to ensure that input data and output
data and databases are correct and continually checked for accuracy and
completeness. This includes ensuring that any regularly scheduled jobs are submitted
and completed correctly. Software and databases should be maintained at (or near) the
current maintenance level. The backup and recovery processes for databases are
normally different
Then day-to-day DASD volume backups. The backup and recovery processes of the
databases should be done as a data/Software administration tasks by a data
administrator.
A checklist of data /Software administration tasks and activities are:
Hardware/Software Requirements
As this project is developed in JAVA, which is platform
independent, so this software can run within any operating system. This
Software needs at least 400 Mhz or hire Processor . RAM required more
then 32 MB for best performance, at least 2.1 Hard Disk is required for
installing this Software but it will refer on the amount of the Database used
for this Software, SVGA, display of 1 MB video memory and color monitor
but with this lot of processor power consumed and speed of the system will
be very slow. Therefore a realistic hardware and software configuration for
this Software is:
RAM : 256 MB
Hard Disk : 40 GB
Printer : Laser
Part 2
Data flow Diagram
Start
gggS
sSSS
sssb
hjStar
Strat the RMI Registry
t Is?
Sendon
Seprate
the
and server
Recive
indow is
Goup
openedChat to and
the message
Run
Run
from The Stop
the
ServerServer
For specific person
No
Yes
Entity-Relationship Diagram:
These are the people, places, things, events and concepts of interest to an organization.
In short, anything which an organization needs to store data about.
Entity relationship diagrams are the abstractions of the real word, which simplify the
problem to be solved while retaining its essential features.
There are three type of relationship, which can exist between two different entities:
• One-to-One Relationships
• One-to-Many Relationships
• Many-to-One Relationships
• Many-to-Many Relationships
The basic things that relates to the tables is by the help of Primary key and Foreign key
concepts.
Primary Key is defined as that unique key that is unique in the whole table and that
cannot be null and duplicate in any circumstances.
Foreign Key is defined as the key that is particularly primary key in other table and
represent as a field in this current table.
Entity
Entity An entity is an object or concept about which you
Want to store information.
Weak Entity
Entity A weak entity is dependent on another entity to exist
Attributes
Attribute Attributes are the properties or characteristics of an
Entity.
Key Attributes
Attribute A key attribute is the unique, distinguishing
Characteristic of the entity. For example, Student’s
Roll No. might be the Student’s key attribute.
Derived attribute
Attribute A derived attribute is based on another attribute. For
example, an employee’s monthly salary is based on
the employee’s annual salary.
Relationship Relationships
Relationships illustrate how to entities share
information in the database structure.
Send
id sid rid & id sid
Reciv
e Chat_Persona
Typ Chat_Message
e msg Flag rid l flag
Part 3
History of JAVA
JAVA
History Of Java
Java was conceived by James Gostling,Patric Naughton,Chris Warth,Ed Frank ,and Mike
Sheridan at Sun Microsystems,Inc. in 1991.It took 18 months to develop the first working
version. This language was initially called “Oak” but was renamed “Java” in 1995.
Forces Behind Java
The original impetus of Java as not Internet! Instead, the primary motivation was the
need for a platform-independent (that is architectural neutral)language that could be used to
create software to be embedded in various electronic devices ,such as microwave ovens nd
remote controls.
The second force was the World Wide Web. With the emergence of WWW,Java was
propelled to the forefront of computer language design, because the Web ,too demanded
portable programs.
Security
When we have a java compatible web browser, we can safely download the Java applets by
confining a Java program to the Java execution and not allowing it access to other part of
computer.
Portability
Many types of computer and operating systems are in use and many are connected through the
Internet. For programs to be dynamically downloaded to all various types of platforms connected
to the Internet, some means of generating portable code is needed.
ByteCode
The Key that allow java to solve the security and portability problems is that output of a Java
compiler is not executable code, rather it is Bytecode.Bytecode is highly optimized set of
instruction designed to be executed by Java run-time System,which is called the JVM(Java
Virtual Machine).JVM is an interpreter for bytecode.
Translating a java program into bytecode helps makes it much easier to run a java program in a
wide variety of platforms. The reason is straightforward:Only the JVM needs to be implemented
for each platform.
RMI Concept
A java object runs within a Java Virtual Machine (JVM).However ,object used by a J2EE
application do not need to run on the same JVM as the J2EE application.This is because a J2EE
application and its components can invoke objects located on a different JVM by using the RMI
system.
RMI is used to connect together a Client and Server.A Client is an application or component that
requires the service of an object to fulfill a request .A Sever creates an object and makes the
object available to clients.A client contacts the server to reference and invoke the object by using
RMI.
A Client locates a remote object by either using RMI naming registry or by passing a string that
references the remote object .In either case, RMI returns a reference to the remote object ,which
is then invoked by the client as if the object was on the local JVM.
Remote Interface
Server-side object that are invoked by remote clients must implements a remote interface and
associated method definitions. The Remote interface is used by clients to interact with the object
using RMI communications. A remote interface extends java.rmi.Remote and each method must
throw a RemoteException.
RMI Process
start rmiregistry
A stub is a java object that reside on the client machine .Its function is to present the same
interface as the remote server. Remote methods calls initiated by the client are actually directed
to the remote server. The stub works with the other parts of the RMI system to formulate a
request that is sent to the remote machine.
A Skeleton is a java object that reside on the server machine.It works with the other parts of the
RMI system to receive request and perform deserialization and invoke the appropriate code on
the server.
Part 4
Data Base Used
Database Used:
Part 5
Screen Shots
Login Window
Once the user login by giving his/her name the following main window will display:
Main Window
Chatting Between two users
Group Chatting
Coding
ChatMain.java
import java.rmi.*;
public interface ChatMain extends Remote
{
public String getValue(String sid)throws RemoteException;
public String getValue(String sid,String rid)throws RemoteException;
public String setValue(String val,String sid)throws RemoteException;
public String setValue(String val, String sid, String rid)throws RemoteException;
public int setName(String nam)throws RemoteException;
public String getName()throws RemoteException;
public void removeName(String nam) throws RemoteException;
public void setPersonal(String sid,String rid)throws RemoteException;
public String getPersonal(String rid)throws RemoteException;
}
ChatImp.java
import java.rmi.*;
import java.rmi.server.*;
import java.sql.*;
//-------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------//
public void run()
{
while(true)
{
try{
// st.executeUpdate("delete from chat_message where flag=1");
st.executeUpdate("delete from chat_personal where flag=1");
Thread.sleep(100000);
}catch(Exception es){System.out.println("Error : " + es);}
}
}
//-------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------//
public String getValue(String sid)
{
int id=0;
str="";
try{
ResultSet rs=st.executeQuery("select * from chat_message where type='G' and flag=0
and rid like '"+sid+"'");
while(rs.next())
{
id=Integer.parseInt(rs.getString(1));
str=rs.getString(5);
st.executeUpdate("update chat_message set flag=1 where id=" + id );
System.out.println(str);
return(str);
}
}catch(Exception e){}
return(str);
}
//-------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------//
public String getValue(String sid,String rid)
{
int id=0;
str1="";
try{
ResultSet rs=st.executeQuery("select id,msg from chat_message where type='P' and
flag=0 and sid='" + sid + "' and rid='"+rid+"'");
while(rs.next())
{
id=Integer.parseInt(rs.getString(1));
str1=rs.getString(2);
}
st.executeUpdate("update chat_message set flag=1 where id=" + id );
}catch(Exception e){}
return(str1);
}
//-------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------//
public String setValue(String val,String sid)
{
String mk1;
try{
ResultSet rs=st.executeQuery("select * from chat_users where id not like
'"+sid+"'");
Statement mst=cn.createStatement();
while(rs.next())
{
count++;
mst.executeUpdate("insert into chat_message values("+count +
",'"+sid+"','"+rs.getString(1)+"','G','"+val+"',0)");
}
}catch(Exception e){System.out.println("Error during writing Data setValue() : " + e);}
return(val);
}
//-------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------//
public String setValue(String val,String sid,String rid)
{
count++;
try{
st.executeUpdate("insert into chat_message values("+count +
",'"+sid+"','"+rid+"','P','"+val+"',0)");
}catch(Exception e){}
return(val);
}
//-------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------//
public int setName(String nam)
{
int flag=0;
try{
ResultSet rs=st.executeQuery("select * from chat_users where id like'" + nam +
"'");
while(rs.next())
{
flag=1;
}
if(flag==0)
{
st.executeUpdate("insert into chat_users values('"+nam+"')");
str=nam + " is Login " + "\n";
if(name==null)
name=nam+":";
else
name=name+nam+":";
}
}catch(Exception e){}
ChatServer.java
import java.rmi.*;
class ChatServer
{
public static void main(String [] args)
{
try
{
ChatImp ct=new ChatImp();
Naming.rebind("bansal",ct);
System.out.println("Server Started Successfully ...");
}
catch(Exception e)
{
System.out.println("Error: to start Server \n " + e );
}
}
}
ChatClient.java
import java.rmi.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/*
<APPLET code=ChatClient.class width=500 height=280></APPLET>*/
try{
int mk;
final ChatMain ct1=(ChatMain)Naming.lookup("rmi://localhost/bansal");
mk=ct1.setName(str);
if(mk==1)
{
txtName.setText("This ID is alrady exist. Give Another ID");
return;
}
this.setVisible(false);
Chat c1=new Chat(str);
c1.setTitle("Chit-Chat : " + str);
c1.setResizable(false);
c1.setSize(1000,420);
c1.setVisible(true);
c1.addWindowListener(new WindowAdapter(){public void
windowClosing(WindowEvent e1){try{ct1.removeName(str);}catch(Exception abc){}System.exit(0);}});
System.out.println("ChatClient: ready ...");
jSP.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jSP.setViewportView(mainText);
lstName=new JList();
jSPl=new JScrollPane();
jSPl.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jSPl.setViewportView(lstName);
msgText=new JTextField("");
sendBut=new JButton("Send");
nou=1;
////////////////////////////////////
jSP.setBounds(225,5,620,335);
l2.setBounds(1,1,220,390);
l3.setBounds(850,5,100,20);
jSPl.setBounds(850,25,140,315);
msgText.setBounds(225,345,680,40);
sendBut.setBounds(910,345,80,40);
cp.add(l2);cp.add(l3);
cp.add(jSP);
cp.add(msgText);
cp.add(sendBut);cp.add(jSPl);
sendBut.addActionListener(this);
msgText.addActionListener(this);
lstName.addMouseListener(this);
///////////////////////////////
try{
ct=(ChatMain)Naming.lookup("rmi://localhost/bansal");
}catch(Exception e){mainText.setText(mainText.getText()+"Error :Can't connect to Server");}
th=new Thread(this,"mk");
th.start();
}
{
public void windowClosing(WindowEvent e1)
{
String tt=p1.getTitle();
tt=tt.substring(tt.indexOf(":")+2);
System.out.println(tt);
p1.setVisible(false);
}
});
}
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
public void mousePressed(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}
public void actionPerformed(ActionEvent ae)
{
try
{
if(ae.getSource()==sendBut || ae.getSource()==msgText)
{
if(msgText.getText().length()<=0)
{
msgText.setText("Enter some message here");
msgText.select(0,msgText.getText().length());
return;
}
st=ct.setValue(sName + " : " +
msgText.getText(),sName);
st1=st;
msgText.select(0,st.length());
st=mainText.getText()+"\n"+st;
mainText.setText("");
mainText.insert(st,0);
}
else if(ae.getSource()==lstName)
{
}
}
catch(Exception abc){}
}
jSP.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jSP.setViewportView(mainText);
sendBut=new JButton("Send");
jSP.setBounds(5,5,300,150);
msgText.setBounds(5,160,225,20);
sendBut.setBounds(235,160,70,20);
cp.add(jSP);cp.add(msgText);
cp.add(sendBut);
msgText.addActionListener(this);
sendBut.addActionListener(this);
try{
ct1=(ChatMain)Naming.lookup("rmi://localhost/bansal");
}catch(Exception e){mainText.setText(mainText.getText()+"Error :Can't connect to Server");}
th=new Thread(this,"mk1");
th.start();
}
public void run()
{
String st;
try{
while(true)
{
st=ct1.getValue(uId,sId);
if(st.length()>0)
{
st=mainText.getText()+"\n"+st;
mainText.setText("");
mainText.insert(st,0);
}
//mainText.insert(st + "\n",0);
Thread.sleep(1000);
}
}catch(Exception es){}
}
}
Part 7
Progress Table
Conclusion
Bibliography
Progress Table:
6. Design DFDs 10-3-2006 11-3-2006 Designed DFDs for the flow of data
9. Integration & 25-4-2006 30-4-2006 Completed all the testing about this
Testing Software
10. Implementation - - -
CONCLUSION
o User Friendly ness is provided, as user has to just login and use the
chat server.
o A user can only login by giving a unique user name.
o A no. of user can login at a time.
o All the information in the database is deleted time to time, so the
size of database will remain null most of the time.
o There are two type of chat facility provided:
- Group chat
- Personal Chat
o Due to lake of time, there are no password mechanism. But soon
I will implement it.
o It’s only a text based chat system, but soon I will implement voice
chat also.
Bibliography
BOOK NAME AUTHOR
Fifth Edition