الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

chat program

مغلق
بدأه suha في 22 سبتمبر 2003 · 5 رد · 1,548 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

hi all!

i really need ur help

i have a project and have no time .i'll write down the program that i need help with:

:

!Lets assume that on a specific time, three buddies (Charles, Lee, and Martin_X) are involved in chatting; see figure-1. Of course, these three buddies are running Chat Client programs on their PCs. The Chat Server program may run in any one of these PCs, or on a separate PC. In figure-1, the chat server runs on a separate PC. Lets assume that the client programs know the IP address of the PC that is running the server program, and the port number through which the chat services are offered. Lets also assume that server is always running (server is never stopped).

1. Starting the Chat Client program

Suppose Charles and Martin_X are already chatting. If Lee wants to join then he must start the client program on his PC. He must also give his nickname as a command-line parameter. For example:

> java ChatClient Lee

If the command-line parameter is not given, then the client program asks for a nickname first. See figure-2. After reading the nickname, the client program contacts the server and sends the nickname to it.

2. Client – Server interaction

If the server is up and running, and there is no communication problems, then the chat client creates a GUI for the user (Lee). GUI is shown in figure-3. Note the following:

• The caption of the GUI is “***** its:Chatting *****”.

• The first panel of the frame is a text area for displaying the messages. Important: the text area shown in figure-3 does not posses scroll bar. You implementation must have vertical and horizontal scroll bars.

• The second panel of the frame is the user input area. The first component is a label showing the nickname of the user (‘Lee’ is figure-3). The second component is a text field for user input.

• The user enters his message in the text field. After writing the message, he presses the “Send” button. The message is then sent to the server; in addition, the text field is cleared.

• The server echoes the message to every one, including the sender. Of course, the server adds the sender’s nickname in capital letters in front of the message; see figure-3.

• If a user want to quit, he simply presses the “Exit” button. In this case, the client first sends a string “quit” to the server so that the server can echo it to everyone. Then the client disconnects the link to the server and finally, it exits.

3. The Server

• The server uses port number 1234 (you are free to choose any other port number).

• Whenever a client contacts for the first time, the server places and the client’s IP address together with the supplied nickname in an array. The server uses this array to echo messages to all the participants. As shown in figure-3, the echoed messages contain the sender’s nickname (in capital letters) as the prefix.

• Server writes all the echoed messages to an ASCII file too. When a message is received right after mid-night, the ASCII file is written (‘dumped’) to hard disk with filename ‘archive_N.txt’, where N is the day of the year (0 – 365).

plz if anyone can help me,write me what should i do,and other tips......

nb:reply as soon as possible.

thanx alot

Suha

#2

l pics ma kano yetla3o.so if u can help u kan enter this site where u can read the question and c the pics

http://ied.ux.his.no/docs/Exercise-I.doc

w shokran ktir

suha

تم تعديل هذه المشاركة بواسطة suha في 22 سبتمبر 2003 في 22:44

#3

السلام عليكم

ان شاء الله اقدر اساعدكم بس مش عارف انتوا وصلتوا لايه وباقى ايه وعندكوا وقت قد ايه

وانا لى تعليقات كتيير على الموضوع ان شاء الله تفيدكوا

سلام

#4

shokran akhy 7osam 3ala al rad.bsara7a ana lessa ma ballasht bel program.akher majal lal taslim howwa fi 1-10-03 ya3ni ba2i osbo3.

iza 3ndak ay nasa2e7 plz ektebli yaha.thanx alot!

#5

السلام عليكم

يا ريت تكتب / تكتبى عربى لانى بصعوبة فهمت الكلام

اولا الموقع دة به كود ماسينجر كامل ربما تستفيدوا منه

http://www.codeproject.com/useritems/Talk2Me.asp

وللدخول يمكنك استخدام الايميل والباسوورد بتوعى لتحميل الكود والبرنامج

وهما

hossam_2m@yahoo.com

Password : 876766443

وطبعا الكود دة للدراسة مش لنقله واى استفسار انا تحت امركم

#6

مرحبا جميعا"

لقد كتبت الكود لكني عندي مشكلة صغيرةوو هي انني اريد ان احصل على زرين واحد مكتوب عليه (exit)و واحد(send)ز

ساكتب الكود فارجو المساعدة

import java.rmi.*;

import java.rmi.registry.*;

import java.rmi.server.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class ClientImpl extends UnicastRemoteObject implements Client, Runnable

{

JFrame frame = new JFrame("Chat klient");

JPanel panel = new JPanel( new BorderLayout(2,2));

JTextField text = new JTextField();

JTextArea messages = new JTextArea();

JLabel status = new JLabel("Type your nick name");

JScrollPane scroll = new JScrollPane(messages);

private String clientname;

private Server server;

private String channel;

public ClientImpl() throws RemoteException{ }

public ClientImpl(String cname) throws RemoteException {

}

public void notifyMessage(Message msg) throws RemoteException {

messages.insert(msg.sourceuser + " - " + msg.tekst + "\n", 0);

}

public String getName() throws RemoteException {

return clientname;

}

public void run() {

/*

try {

Client c = new Client();

}

catch (Exception e){

System.out.println(e);

System.exit(1);

}*/

messages.setEditable(false);

panel.add(text, BorderLayout.NORTH);

panel.add(scroll, BorderLayout.CENTER);

panel.add(status, BorderLayout.SOUTH);

frame.getContentPane().add(panel, BorderLayout.CENTER);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

text.addActionListener( new textInserted(this));

scroll.setVisible( false );

frame.setSize(200,300);

frame.show();

}

public class textInserted implements ActionListener

{

private Client client;

textInserted(Client c) {client = c;}

public void actionPerformed ( ActionEvent e)

{

if (status.getText().compareTo("Type you nick name")==0)

{

clientname = text.getText();

text.setText("");

status.setText("Skriv inn Channel name");

} else if (status.getText().compareTo("Skriv inn Channel name")==0) {

channel = text.getText();

text.setText("");

status.setText("Skriv inn servernavn");

} else if ( status.getText().compareTo( "Skriv inn servernavn") ==0 ) {

try {

Registry reg = LocateRegistry.getRegistry("localhost");

server = (Server) reg.lookup(text.getText());

text.setText("");

server.connect(channel, client);

scroll.setVisible(true);

}

catch(Exception err){

System.out.println("Aaaaaaa ...\n" + err);

System.exit(1);

}

status.setText("Skriv \"exit\" for ه avslutte.");

} else {

Message msg = new Message();

msg.sourceuser = clientname;

msg.targetuser = "all";

msg.tekst = text.getText();

text.setText("");

if (msg.tekst.compareToIgnoreCase("exit")==0) {

try { server.disconnect(channel, client); } catch(Exception e1){System.out.println(e1);}

System.out.println("Quiting.");

frame.removeAll();

frame.setVisible(false);

//System.exit(0);

}

try { server.newMessage(channel, msg); } catch(Exception e2){System.out.println(e2);}

}

}

}

}

هذا الموضوع مغلق.

مواضيع مشابهة