File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes Simple Chat Application ideas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Simple Chat Application ideas" Watch "Simple Chat Application ideas" New topic
Author

Simple Chat Application ideas

Stevie Shorey
Ranch Hand

Joined: Dec 10, 2012
Posts: 45

I am trying to make a very simple chat program using RMI (no GUI's) but i am struggling for ideas. How do i register clients when they connect to the server? When i use

RemoteServer.getClientHost()

all this does is show the ip address (and they are the same for all clients that connect from the same computer (from multiple command windows). What i am trying to implement is this: when a client logs on he is shown a switch-case menu and ift they press

1. they get a list of connected clients.

2. sendMessage(client, String)

But i do not know how to identify individual clients?

And when i do, how do i show a string only on that client's window ?

Thanks,

Research: (i have looked at ideas on the web but a lot of them are more advanced than i want. This is a simple application and i do not want to complicate it / copy code i dont understand).
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

The simple answer is: There is no API to identify a particular caller. Do it yourself.

How? Pass a string, or some id at sign-on time to associate a user and continue to pass that id for every call thereafter.

How else? You said you didn't like the other complex methods, so innovate.


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
Stevie Shorey
Ranch Hand

Joined: Dec 10, 2012
Posts: 45

Edward Harned wrote:The simple answer is: There is no API to identify a particular caller. Do it yourself.

How? Pass a string, or some id at sign-on time to associate a user and continue to pass that id for every call thereafter.

How else? You said you didn't like the other complex methods, so innovate.


I appreciate your reply, but can you be a bit more specific please?

So at sign-on time, i pass a string which is the "username". Now how do i talk t just this particular client? Since "there is no API to identify a particular caller", how do i do it myself?

Thanks,
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

Now it gets interesting.

RMI is a single session -- A contacts B, B responds to A. Done

What you want is sessions going both ways. B, the service, can send messages to A, C, D, etc.

In order to do that, the clients need to become RMI servers. This is very similar to RMI callback -- the clients need to implement a Remote interface, so the server can call them back. There are examples here to do that. There are tutorials on the internet, etc.

Once you do it once, it becomes simple.
Stevie Shorey
Ranch Hand

Joined: Dec 10, 2012
Posts: 45

Edward Harned wrote:Now it gets interesting.

RMI is a single session -- A contacts B, B responds to A. Done

What you want is sessions going both ways. B, the service, can send messages to A, C, D, etc.

In order to do that, the clients need to become RMI servers. This is very similar to RMI callback -- the clients need to implement a Remote interface, so the server can call them back. There are examples here to do that. There are tutorials on the internet, etc.

Once you do it once, it becomes simple.


That phrase has been what i have been looking for : RMI Callback
Thanks so much for that!!!
kanna naha
Greenhorn

Joined: Mar 26, 2013
Posts: 3
This can be really useful and that can be processed in a required on one that can be measured/.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple Chat Application ideas