Viewing Clients in a Chat Program

Discussion in 'Java' started by joanduan, Apr 11, 2004.

  1. joanduan

    joanduan Guest

    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
    joanduan, Apr 11, 2004
    #1
    1. Advertising

  2. 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
    Roman Vottner, Apr 11, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. joanduan
    Replies:
    0
    Views:
    319
    joanduan
    Apr 10, 2004
  2. Replies:
    0
    Views:
    2,174
  3. Larion
    Replies:
    1
    Views:
    1,819
    jcsnippets.atspace.com
    Mar 26, 2006
  4. Sullivan WxPyQtKinter

    To my clients force to terminate a python CGI program?

    Sullivan WxPyQtKinter, Mar 28, 2006, in forum: Python
    Replies:
    0
    Views:
    307
    Sullivan WxPyQtKinter
    Mar 28, 2006
  5. Francesco
    Replies:
    1
    Views:
    512
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Dec 27, 2006
Loading...

Share This Page