Pattern/s sought for chat client implementation

Discussion in 'Java' started by Karsten Wutzke, Aug 14, 2007.

  1. Hello!

    I'm developing a chat client and I'm looking for the right pattern for
    the object/s that handle the messages between the client and server.
    The users can participate in several chats at once. You can think of
    it as an IRC client basically, much like ICQ, MSN, AIM or such, just
    with many people in a chat (chatroom).

    I'm currently looking at the Proxy pattern. Don't know if I might need
    a Facade pattern, Chain of Responsibility pattern doesn't seem to
    apply, but I'm not sure if I'm on the right track here.

    That object being responsible will likely need to dispatch the
    incoming messages to the respective chat windows.

    Can anyone give some assistance please?

    Since the client is implemented in Java what other classes/packages
    might be important to mention?

    TIA
    Karsten
     
    Karsten Wutzke, Aug 14, 2007
    #1
    1. Advertising

  2. Karsten Wutzke

    Daniel Pitts Guest

    On Aug 14, 5:44 am, Karsten Wutzke <> wrote:
    > Hello!
    >
    > I'm developing a chat client and I'm looking for the right pattern for
    > the object/s that handle the messages between the client and server.
    > The users can participate in several chats at once. You can think of
    > it as an IRC client basically, much like ICQ, MSN, AIM or such, just
    > with many people in a chat (chatroom).
    >
    > I'm currently looking at the Proxy pattern. Don't know if I might need
    > a Facade pattern, Chain of Responsibility pattern doesn't seem to
    > apply, but I'm not sure if I'm on the right track here.
    >
    > That object being responsible will likely need to dispatch the
    > incoming messages to the respective chat windows.
    >
    > Can anyone give some assistance please?
    >
    > Since the client is implemented in Java what other classes/packages
    > might be important to mention?
    >
    > TIA
    > Karsten


    Generally, you don't start out looking for patterns to implement, you
    think about how you want to implement it, and the see which patterns
    that implementation is like.

    If all your chat client/servers are always going to be java, you might
    consider RMI.

    If you want to define your own wire protocol, then you should instead
    define that protocol first, and implement an API that lets you send
    and receive messages.

    Something as simple as a chat client/server shouldn't be over
    thought.

    Basically, you might have something like:

    A shared library: Contains necessary code to send and recieve messages
    A client: Presents the messages and actions to a user
    A server: Recieves a messages, processes them, and sends them back out
    to the clients.
     
    Daniel Pitts, Aug 14, 2007
    #2
    1. Advertising

  3. On 14 Aug., 21:41, Daniel Pitts <> wrote:
    > On Aug 14, 5:44 am, Karsten Wutzke <> wrote:
    >
    >
    >
    > > Hello!

    >
    > > I'm developing a chat client and I'm looking for the right pattern for
    > > the object/s that handle the messages between the client and server.
    > > The users can participate in several chats at once. You can think of
    > > it as an IRC client basically, much like ICQ, MSN, AIM or such, just
    > > with many people in a chat (chatroom).

    >
    > > I'm currently looking at the Proxy pattern. Don't know if I might need
    > > a Facade pattern, Chain of Responsibility pattern doesn't seem to
    > > apply, but I'm not sure if I'm on the right track here.

    >
    > > That object being responsible will likely need to dispatch the
    > > incoming messages to the respective chat windows.

    >
    > > Can anyone give some assistance please?

    >
    > > Since the client is implemented in Java what other classes/packages
    > > might be important to mention?

    >
    > > TIA
    > > Karsten

    >
    > Generally, you don't start out looking for patterns to implement, you
    > think about how you want to implement it, and the see which patterns
    > that implementation is like.
    >
    > If all your chat client/servers are always going to be java, you might
    > consider RMI.
    >
    > If you want to define your own wire protocol, then you should instead
    > define that protocol first, and implement an API that lets you send
    > and receive messages.
    >
    > Something as simple as a chat client/server shouldn't be over
    > thought.
    >
    > Basically, you might have something like:
    >
    > A shared library: Contains necessary code to send and recieve messages
    > A client: Presents the messages and actions to a user
    > A server: Recieves a messages, processes them, and sends them back out
    > to the clients.


    The chat app is not Java only. The server component can basically be
    anything, as well as the protocol to use. I want to design for that.
    So RMI seems out of the question.

    It looks like proxy is the right thing here, facade maybe, chain of
    responsibilty not really.

    I now wonder about the proxy stuff Java has to offer (new thread).

    Karsten
     
    Karsten Wutzke, Aug 15, 2007
    #3
  4. Karsten Wutzke

    Bjorn Borud Guest

    [Karsten Wutzke <>]
    | Hello!
    |
    | I'm developing a chat client and I'm looking for the right pattern for
    | the object/s that handle the messages between the client and server.


    start by modeling the data flow.

    -Bjørn
     
    Bjorn Borud, Aug 23, 2007
    #4
  5. Karsten Wutzke

    Bjorn Borud Guest

    [Karsten Wutzke <>]
    | It looks like proxy is the right thing here, facade maybe, chain of
    | responsibilty not really.

    I've designed and implemented several chat servers, chat clients and
    similar message-oriented systems, and I can't say that it makes any
    sense to start off with the sort of patterns you want to use -- I am
    not even sure where in the design you want to use them.

    -Bjørn
     
    Bjorn Borud, Aug 23, 2007
    #5
  6. Bjorn Borud wrote:

    > [Karsten Wutzke <>]
    > | Hello!
    > |
    > | I'm developing a chat client and I'm looking for the right pattern for
    > | the object/s that handle the messages between the client and server.
    >
    >
    > start by modeling the data flow.
    >
    > -Bjørn


    If the OP hasn't got his/her head around it, the communication goes this
    way:
    1) Server listens for incomming connection on certain address on a certain
    port.
    2) Client connects to server on the address on that particular server's
    port.
    3) Client requests some data from the server
    4) Server handles the request, processes it, sends it off to the client.
    5) Client handles the data, processes it and presents it to the user
    interface.

    This is the most simple schematic view of the whole application as it can
    get (intracacies has been left out for clarity and conciseness).

    If by pattern, you mean Gamma et. al ones, you could read up on composite,
    singleton and especially observer/client patterns.


    HTH

    --
    Cheers,
    Ishwor Gurung
    /* humpty dumpty */
     
    Ishwor Gurung, Aug 23, 2007
    #6
    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. Jason Walraven

    Client-side chat

    Jason Walraven, Apr 6, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    712
    Jason Walraven
    Apr 6, 2004
  2. andreas

    chat client alpha version

    andreas, Sep 16, 2004, in forum: Java
    Replies:
    4
    Views:
    352
  3. Replies:
    0
    Views:
    2,237
  4. Rudolf W. MEIJER
    Replies:
    0
    Views:
    475
    Rudolf W. MEIJER
    Mar 12, 2008
  5. Roedy Green

    simple regex pattern sought

    Roedy Green, May 25, 2012, in forum: Java
    Replies:
    18
    Views:
    409
Loading...

Share This Page