Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple Chat Application ideas

 
Stevie Shorey
Ranch Hand
Posts: 45
Android Chrome Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stevie Shorey
Ranch Hand
Posts: 45
Android Chrome Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 291
Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
Android Chrome Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This can be really useful and that can be processed in a required on one that can be measured/.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic