Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AJAX,WebSockets, XMPP?

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Imagine a online-game with two players (clients).

What is the best technique to guarantee
that these two players are able to play interactivately,
that means player 1 sees the changes of player 2 immediately and both can react simultaneously ("real-time communication").

I guess, AJAX (DWR, Direct Web Remoting) is too slow.
So should I go for WebSockets or XMPP or JMS(Java Messaging Service) or SERVLET API 3.0 (with its "COMET-API")
or is there another techinque which is the right thing for that kind of web-application?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a whole bunch of acronyms that are only vaguely related to each other, and if it's a *web* app, a couple aren't even applicable unless you're using an applet.

Have you *proven* that Ajax doesn't work they way you need it to?

Define "immediately", since it's *obvious* "immediate" is impossible, regardless of *any* method you use.
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello David,

actually I am trying/learning WebSockets by using JETTY-Servlet-Container
(which has built-in support for WebSockets).

Unfortunately, there is no XMPP-Server-Support for any Servlet-Based-Container
(such as Tomcat/Jetty, JBoss, Glashfish,..), so I need to have an additional XMPP-Server
(http://www.saint-andre.com/jabber/jsc/) running simultanously with my JETTY.
That is annoying. So I guess, I do not use XMPP and use WebSockets instead.


Have you *proven* that Ajax doesn't work they way you need it to?


I have been using ajax quite often without problems.
However, I want to give a try to use WebSockets or XMPP instead of Ajax (or Comet)
as I want to have a web based real-time-application.

Bye.

 
Jonas Jacobi
Author
Greenhorn
Posts: 25
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Nimo,

I believe there is a misunderstanding here. WebSockets is not a replacement or a better Ajax. You should look at WebSockets the same way you look at a TCP socket. Instead of coding against the WebSocket APIs directly, you should use a protocol client such as XMPP that has been built on top of the WebSocket API. This will let you communicate directly with the XMPP server from the browser via a WebSocket-enabled server (if the server has been properly designed).

A demo example of how this can be done you can see here - http://www.kaazing.me This site shows how you can use XMPP over WebSockets to communicate with Google Talk (hint: use your Google account to login and chat).

Or, you can read this article - http://www.sys-con.com/node/779407 - which covers this topic well.

Cheers,
Jonas
Author Pro JSF and Ajax
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic