I'm working on tricky ways to get Javascript clients and a Ruby on Rails server to send messages back and forth to each other. I've settled on a polling mechanism, this works fine in my particular case because the two users who are communicating with each other have to have a high polling rate only at the initiation of the connection, and after that, we can get by with a low polling rate to make sure the other user hasn't gone away.
However, if you wanted to do things in a more real-time way, polling might lag a bit too much for you. In that case, you might want to use a technology such as Comet to push data from the server to the client.
If you want to use this with Ruby on Rails, Christopher Cyll came up with an interesting way to do it that he calls The Mongrel Comet. It's pretty rough and hacky right now, but an interesting idea.