Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Viewing Clients in a Chat Program

Reply
Thread Tools

Viewing Clients in a Chat Program

 
 
joanduan
Guest
Posts: n/a
 
      04-11-2004
I have developed a chat program in java. using server socket and
simple socket. The server and client open a DataInputStream and
DataOutputStream Reader. There are two problems that i want to
resolve.

1) I want to show all the currently connected clients in a JList
present in Client GUi.

2) I also want to be able to communicate privately with the other
users and also send binary files like images and audio files

I have created a TrackUser Class which stores info about the user.
However the main problem remains the same, How to send the information
back to the client and display it in a Jlist cause there's gonna be a
lot of info flowing between the server and the client (redirected
obviously from another client) the main problem lies in identifying
which part belongs to userinfo and which part belongs to the chat
portion. When the server sends user information to the client that
appears in the Client textarea whereas i want the list of users in a
JList and the chat in the textarea.

Thanx
 
Reply With Quote
 
 
 
 
Roman Vottner
Guest
Posts: n/a
 
      04-11-2004
hi,

joanduan wrote:

> 1) I want to show all the currently connected clients in a JList
> present in Client GUi.
>
> ...
>
> I have created a TrackUser Class which stores info about the user.
> However the main problem remains the same, How to send the information
> back to the client and display it in a Jlist cause there's gonna be a
> lot of info flowing between the server and the client (redirected
> obviously from another client) the main problem lies in identifying
> which part belongs to userinfo and which part belongs to the chat
> portion. When the server sends user information to the client that
> appears in the Client textarea whereas i want the list of users in a
> JList and the chat in the textarea.
>


i would create a hashtable on the server which contains the username as key
(or an id if multiple names should be supported) and the TrackUser-class
which contains the users' information as the value. on login of a user you
iterate through the hashtable of online-users and send just the name of the
user who loged in to them.

the sending message contains for example an additional header (just a fixed
size of data) which defines the type of message (userinfo, chatmsg, ...)
the message represents and the message itself. thisway you can catch the
whole message at receiving and deceide what to do with it as you read the
header of the message.

at http://www.brackeen.com/javagamebook/ you can download the source of
chapter6 which creates a client/server game- and chat-architecture, which
can be extended by "modules" or "plugins". it uses java.nio to communicate
but the idea itself should work for Serversockets too.

lg,
roman



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Authentication for web clients and Swing clients Francesco Java 1 12-27-2006 03:10 AM
Build a simple Textual Chat with Java - 2 Clients and 1 Server: Help Me !! Larion Java 1 03-26-2006 06:48 PM
Chat Server and Chat Client for INTRANET diptanu@gmail.com Java 0 01-30-2006 06:56 PM
PC Viewing vs DVD Player Viewing - MP3 play very fast Ray Donzdorf Computer Support 0 12-11-2004 01:07 PM
Viewing Clients in a Chat Program joanduan Java 0 04-10-2004 07:40 AM



Advertisments