Pattern/s sought for chat client implementation

K

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.
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
 
D

Daniel Pitts

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.
 
K

Karsten Wutzke

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
 
B

Bjorn Borud

[Karsten Wutzke <[email protected]>]
| 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
 
B

Bjorn Borud

[Karsten Wutzke <[email protected]>]
| 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
 
I

Ishwor Gurung

Bjorn said:
[Karsten Wutzke <[email protected]>]
| 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top