You are on page 1of 22

A PROJECT REPORT

ON
CHAT SERVER
Submitted in partial fulfillment of the requirements for the award of degree of
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE & ENGINEERING

Submitted to:
Prof. Isha Sharma

Submitted By:
Spandan Roy
16BCS1127

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


Chandigarh University, Gharuan

Nov 2017
Table of Contents

Sr. No. Topic Page No.

i. Acknowledgement i

ii. Abstract ii

Ch-1 Introduction 1

Ch-2 Methodology 2

Ch-3 Testing 6

Ch-4 Source Code 8

Ch-5 Outputs 15

Ch-6 Limitation and Future Enhancement Conclusion 16

References 17
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

ACKNOWLEDGEMENT

We express our deep sense of gratitude to our respected and learne


d guides, Prof. Jaspreet Singh and Prof. Isha Sharma for their valuable
help and guidance, we are thankful to them for the encouragement they
have given us in completing the project.

We are also grateful to respected Prof. Vivek Ghai, Coordinator


BE CSE, Assistant Professor (CSE-UIE) and to our respected Prof. Dr.
Satbir Sehgal, Director Engineering, Chandigarh University for
permitting us to utilize all the necessary facilities of the institution.

We are also thankful to all the other faculty & staff members of
our department for their kind co-operation and help.

Lastly, we would like to express our deep apperception towards our


classmates and our indebt ness to our parents for providing us the moral
support and encouragement.

Spandan Roy
(16BCS1127)

i
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

ABSTRACT

Chatting is now-a-days very useful to express our ideas as well as receive others
ideas on any topic. Chats reflect the recent trends of the society. Sometimes, it is
possible to meet eminent people in chatting and have their advice.

Corporate messenger is a graphical chatting application that makes chatting a


pleasant experience. It has excellent features that make any user do whatever he wants
while chatting.

Corporate messenger has two types of users: 1. Admin and 2. Client

Admin can do the following activities:

1. User Management: He makes some initial startup tasks while starting the chat server.

He can create new users and allow or disconnect the users. Admin can also close the
chat session, so that all the users will be disconnected.

2. Administrative Client: Admin can also involve in chatting as a client from his admin
console using this option.

3. Shutdown: He can shut down the chat server.

4. Log Charts: He can create log charts which contain information of how chatting has
taken place.

Client can perform the following tasks:

1. Connect: He can connect himself to chat server by typing his username and password.

2. Chat: He can participate in chatting by entering into a chat room.

3. View this User Info: He can also his own profile and options.

ii
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

4. Display activity of user: When chatting is done, whether the other user is sending
text or images is also displayed on his console.

5. Room management: He can create his own chat rooms based on a subject and invite
others to enter that room. He can also save the chat data separately.

6. Instant messages: It is possible to send instant messages and popups to other users
who are in chatting.

7. Canvas management: Chat Space Instant Messenger is a graphical chatting


application. It enables the clients to draw shapes and apply colors and save them. Client
can also show or hide the canvas depending on his interest.

8. Copy & Paste: He can also perform operations like copying earlier text into chat text.
It is also possible to copy pictures and save them in a file.

9. Chat Room control: He can manage the connection settings and control the chat room
settings.

10. Manual: In case any help needed, the client can go through the in-built manual
available.

iii
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

INTRODUCTION

1. Introduction

Teleconferencing or Chatting, is a method of using technology to bring people


and ideas “together” despite of the geographical barriers. The technology has been
available for years but the acceptance it was quite recent. Our project is an example of
a chat server. It is made up of 2 applications the client application, which runs on the
user’s Pc and server application, which runs on any Pc on the network. To start chatting
client should get connected to server where they can practice two kinds of chatting,
public one (message is broadcasted to all connected users) and private one (between
any 2 users only) and during the last one security measures were taken.

1
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

METHODOLOGY

2. System Analysis

Existing System:

The existing communication system is not built as a software


application. Everybody communicates with others physically or through the
mails. To make this complex communication job simple and allows the users to
participate in live communication and save unproductive time it is to be built as
a software application.
Each and every user or employee of an organization has to register, get
into his inbox and check for his mail which doesn’t provide live communication
resemblance to the user. This facility does not categorize the users depending
on their interests. This type of communication channel fails in providing
effective user-friendly communication between the users. If this channel grows
up to some extent then it will be harder to place some restrictions on the users.
As a result, ineffective communication wastes the user time.

Proposed System:

The first step of analysis process involves the identification of need. The
success of a system depends largely on how accurately a problem is defined,
thoroughly investigated and satisfying the customer needs by providing user
friendly environment
This system has been developed in order to overcome the difficulties
encountered while using the mailing system for communication between the
users. Providing user friendly communication channel, live communication
facility, categorizing the users, sending public & private messages, sending
instant & offline messages, graphical communication are motivating factors for
the development of this system.

2
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

Scope and Objectives:

 This can be treated as a product mainly used in chatting kind of


communication products to exchange the information between the by
storing the users’ info and his connection details, chatroom control
 Panel (invite, ban and allow) details and chatroom management details.
It also helps the administrator to monitor the chatroom by generating
different kinds of reports like users currently available in the chatroom,
banned list of users and allows the users to view the offline messages
individually. Lot of effort was put to make it user friendly.
 Optimum utilization of system is possible. All basic functionalities are
provided.
 Reduces the user manual communication work.
 The wastage of time is reduced.
 It also helps in providing instant and offline communication.
 More flexible, it means we can continue to use the same system even the
no of users up to maximum level.

1. User Management Module: It allows the administrator to view the list of users
or information corresponding to a user and banned list of users. It provides a facility to
log the user chatting transaction in to log files.

2. Messages Module: It also generates user wise list of offline messages.

External Interface Requirements:


1.1 User Interface: This application provides Java Applet based
GUI interface for the administrator to start the server at the
particular port no and set the preferences and settings. The normal
users can connection to server and start using the option through
similar kind of interface.
1.2 Software Interfaces: These interface requirements should
specify the interface with other. Software which the system will use

3
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

or which will use the system, this includes the interface with the
operating system and other applications.
The message content and format of each interface should be given.

1.3 Hardware Interfaces: Hardware interface is very important


to the documentation. If the software is executed on existing
hardware or on the pre-determined hardware, all the characteristics
of the hardware, including memory restrictions, should be specified.
In addition, the current use and load characteristics of the hardware
should be given.
2. Design constraints
2.1 Software constraints :

Operating System : Windows 7 and above

Forms & Reports : Java Applet & AWT

Other Softwares : JDK1.7 and above

2.2 Hardware Constraints :


Processor : Intel i3 or above

RAM : 1 GB

Hard Disk : 20 GB

CD/ROM Drive : 52X

VDU : VGA

Key Board : 101 Standard

Approach:

The tool has been designed using Java Applet.

4
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

Methodology:

The user interacts with the tool using a GUI.


 The GUI operates in one form- the chat form.
 The chat form makes the actual communication possible in the form of
text.

Operational Concepts and Scenarios:

Operation of the application based on the inputs given by the user:

Chat form:
 Contains a rich textbox which cannot be edited but only displays the
messages from one user to another, including the self-sent message, as
in any chat application.
 Contains a textbox for messages to be written that is sent across the
network.
 Contains a Send button.
 When the sent button is clicked, in the background, the text in the
textbox is encoded and sent as a packet over the network to the client
machine. Here this message is decoded and is shown in the rich
textbox.
 To make it more realistic, the self-sent message is shown in the rich
textbox as well. Both the messages are differentiated by the help of the
identifier name at the beginning of each message in the rich text box.

EXIT:
The user exits the software in one scenario:
 Exits the chat form, this is when the application is closed.

5
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

TESTING

Glen Myers states a number of rules that can serve well as testing objectives.
Testing is a process of executing a program with the intent of finding an error. We can
test our project MNM Chat using various methods but the main objective is that
when: -
1. The first form displays all the systems connected to a network correctly.

2. A successful connection is created and communication is possible via text


synchronously.

3.1 TESTING OBJECTIVES:

Unit testing is the testing of the individual components (units) of the software.
Unit testing is conducted as part of a combined code and unit test phase of the
software lifecycle, although it is not uncommon for coding and unit testing to be
conducted as two distinct phases.
When developing a strategy for unit testing, there are three basic
organizational approaches that can be taken. These are top down, bottom up and
isolation. In our case of MNM Chat we simply use top down approach. There are two
sub options in our project first one is Form1 mode, which is the listing part and
second one is Form2 mode which is chat box. In the first case we just test for the
correct resolution of names of systems connected to a network. And in the second
mode our motive is to obtain a two-way communication between the host user and
remote user. And we are very much successful here in our test case.

3.2 INTEGRATION TESTING:


After the unit testing we have to perform integration testing. The goal here is
to see if modules can be integrated properly, the emphasis being on testing interfaces
between modules. After the modules are connected we have perform the total testing.
3.3 SYSTEM TESTING:

6
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

System testing is the process of executing software in a controlled manner, in


order to answer the questions "Does the software behave as specified?"
System testing is often used in association with the terms verification and validation.
Verification is the checking of items, including software, for conformance and
consistency with an associated specification. Software testing is just one kind of
verification, which also uses techniques such as reviews, analysis, inspections and
walkthroughs. Validation is the process of checking that what has been specified is
what the user actually wanted.
Validation: Are we doing the right job?
Verification: Are we doing the job, right?

The test strategies will include three different types of testing as describes below: -

1. Logical Testing: This will be used to test every aspect of both modes, report
and query as soon as it is implemented, using valid, invalid and extreme data test data
will be added to test each code module and results compared with the expected
results. Sufficient data will be added to ensure that there is at least one entry in each
category.
Subsequent tests will often involve adding new data, which will be deleted when the
test works satisfactorily.
As per our requirement we have also included some field such as character size etc
and then queries were performed after that results were tabulated and then the module
was free from extra field.

2. Functional Testing: - In this menu items were tested to ensure no functions


has been missed out. This is done for the smooth working of the project.

3. System Testing: - This is done after the completion of system; all the queries
were carried out again to ensure that no errors have been introduced.

7
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

SOURCE CODE

4.1. Sever Class

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class Server extends Applet implements ActionListener, Runnable
{
Image Icon =
Toolkit.getDefaultToolkit().getImage("D:/Example/emperian/jsf/ChatterAPI/src/
chatterapi/hi.gif");
ServerSocket ss;
Socket s;
BufferedReader br;
BufferedWriter bw;
TextField text;
Button sendBut, exitBut;
List list;
@Override
public void init(){
setForeground(Color.blue);
getAppletContext().showStatus("...");

@Override

8
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

public void start() // class constructor


{
// super(m);
setSize(300, 130);
setLocation(0,0);
// setIconImage(Icon);
// setResizable(false);
setBackground(new Color(192, 192, 192));
this.setLayout(new GridLayout(2, 1));

Panel panels[] = new Panel[2];


panels[0] = new Panel();
panels[1] = new Panel();
panels[0].setLayout(new BorderLayout());
panels[1].setLayout(new FlowLayout(FlowLayout.LEFT));

sendBut = new Button("Send");


exitBut = new Button("Exit");

sendBut.addActionListener(this);
exitBut.addActionListener(this);

list = new List();


list.select(list.getItemCount()-1);

text = new TextField(25);

panels[0].add(list);
panels[1].add(text);

9
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

panels[1].add(sendBut);
panels[1].add(exitBut);
add(panels[0]);
add(panels[1]);
showStatus("......");
setVisible(true);

try
{ showStatus("connecting ....");
list.add("Send request plz wait...");
ss = new ServerSocket(1051);//some port number, better be above
1000
s = ss.accept();
br = new BufferedReader(new
InputStreamReader(s.getInputStream()));
bw = new BufferedWriter(new
OutputStreamWriter(s.getOutputStream()));
bw.write("Hi!?");
bw.newLine();
bw.flush();
Thread th;
th = new Thread(this);
th.start();

}catch(Exception e){System.out.println("Error:"+e);}
}
public void run()
{
while (true)
{

10
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

try
{ showStatus("connected....");
list.add("R: "+br.readLine());
list.select(list.getItemCount()-1);

}catch (Exception e){System.out.println("Error:"+e);}


}
}

public void actionPerformed(ActionEvent ae)


{
if (ae.getSource().equals(exitBut))
System.exit(0);
else
{
try
{
bw.write(text.getText());
list.add("S: "+text.getText());
showStatus("Data sent...");
list.select(list.getItemCount()-1);
bw.newLine();bw.flush();
text.setText("");
}catch(Exception x){System.out.println("Error:"+x);}
}
}

11
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

4.2.Client Class

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;

public class Client extends Applet implements ActionListener, Runnable


{

Image Icon =
Toolkit.getDefaultToolkit().getImage("D:/Example/emperian/jsf/ChatterAPI/src/
chatterapi/hi.gif") ;

Socket s;
BufferedReader br;
BufferedWriter bw;
TextField text;
Button sendBut, exitBut;
List list;
@Override
public void init(){
setForeground(Color.blue);
getAppletContext().showStatus("...");

@Override
public void start()
{

setSize(300, 130);
//setIconImage(Icon);
setLocation(300,0);
// setResizable(false);
setBackground(new Color(192, 192, 192));
this.setLayout(new GridLayout(2, 1));

Panel panels[] = new Panel[2];


panels[0] = new Panel();
panels[1] = new Panel();
panels[0].setLayout(new BorderLayout());
panels[1].setLayout(new FlowLayout(FlowLayout.LEFT));

sendBut = new Button("Send");

12
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

exitBut = new Button("Exit");

sendBut.addActionListener(this);
exitBut.addActionListener(this);

list = new List();

text = new TextField(25);

panels[0].add(list);
panels[1].add(text);
panels[1].add(sendBut);
panels[1].add(exitBut);

add(panels[0]);
add(panels[1]);

setVisible(true);

try
{
/* Assuming that this application is run on single
machine I've used the default ip i.e., 127.0.0.1. If
you want to use it on 2 different machines use the
ip that is assigned to the machine on which server
applicatin is residing*/

s = new Socket("127.0.0.1", 1051);


br= new BufferedReader(new
InputStreamReader(s.getInputStream()));
bw = new BufferedWriter(new
OutputStreamWriter(s.getOutputStream()));
Thread th;
th = new Thread(this);
th.start();

}catch(Exception e){System.out.println("Error:"+e);}

public void run()


{
while (true)
{
try
{
list.add("R: "+br.readLine());

13
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

list.select(list.getItemCount()-1);
showStatus("connected..");
}catch (Exception h){System.out.println("Error:"+h);}
}
}

public void actionPerformed(ActionEvent ae)


{
if(ae.getSource().equals(exitBut))
System.exit(0);
else
{
try
{
bw.write(text.getText());
showStatus("connected..");
list.add("S: "+text.getText());
showStatus("Data sent...");
list.select(list.getItemCount()-1);
bw.newLine();
bw.flush();
text.setText("");
}catch(Exception m){System.out.println("Error:"+m);}
}

14
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

OUTPUTS
(Snapshots of Frontend)

Fig.5.1. Server Applet

Fig.5.2. Client Applet

15
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

LIMITATION AND FUTURE


ENHANCEMENT CONCLUSION

6.1 Limitations
There are mainly two limitations of the project and that are:
 The firewall is to be disabled for intra network.
 It is dependent on the specific algorithm used.

6.2 Future Enhancement Conclusion


There is always a room for improvements in any software package, however
good and efficient it may be done. But the most important thing should be
flexible to accept further modification. Right now, we are just dealing with text
communication. In future this software may be extended to include features such
as:
 File transfer: this will enable the user to send files of different formats
to others via the chat application.
 Voice chat: this will enhance the application to a higher level where
communication will be possible via voice calling as in telephone.
 Video chat: this will further enhance the feature of calling into video
communication.

16
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)

REFERENCES
Books referred:

 Java: The Complete Reference


- by Herbert Schildt

 Introduction to Java Programming


- by Y. Daniel Liang

Internet References: -

 www.books.google.co.in
 www.howstuffworks.com
 www.wikipedia.org
 www.javaworld.com
 www.sun.com

17

You might also like