Java Final Project
Java Final Project
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
Nov 2017
Table of Contents
i. Acknowledgement i
ii. Abstract ii
Ch-1 Introduction 1
Ch-2 Methodology 2
Ch-3 Testing 6
Ch-5 Outputs 15
References 17
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)
ACKNOWLEDGEMENT
We are also thankful to all the other faculty & staff members of
our department for their kind co-operation and help.
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.
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.
4. Log Charts: He can create log charts which contain information of how chatting has
taken place.
1. Connect: He can connect himself to chat server by typing his username and password.
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.
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
1
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)
METHODOLOGY
2. System Analysis
Existing System:
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)
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.
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.
RAM : 1 GB
Hard Disk : 20 GB
VDU : VGA
Approach:
4
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)
Methodology:
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.
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.
6
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)
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.
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
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)
sendBut.addActionListener(this);
exitBut.addActionListener(this);
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);
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.*;
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));
12
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)
sendBut.addActionListener(this);
exitBut.addActionListener(this);
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*/
}catch(Exception e){System.out.println("Error:"+e);}
13
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)
list.select(list.getItemCount()-1);
showStatus("connected..");
}catch (Exception h){System.out.println("Error:"+h);}
}
}
14
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)
OUTPUTS
(Snapshots of Frontend)
15
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)
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.
16
CHAT SERVER 3rd Semester SPANDAN ROY (16BCS1127)
REFERENCES
Books referred:
Internet References: -
www.books.google.co.in
www.howstuffworks.com
www.wikipedia.org
www.javaworld.com
www.sun.com
17