How to use WebSocket with a Jetty emdedded custom server

I'm new to StackOverflow. I've searched about the topic, but I did not find anything really relevant.

Basically I need to develop a web 'Support Chat' system for our company. I know that there are a lot of available solutions out of there, but we need a custom solution in Java. We need to build a Support Chat web system where users that visit the web site can ask for support using the chat, and on the other side we have 'n' agents that take care of requests. We need to store each bit of conversation in our Cassandra cluster for Business Intelligence purpose. We need to develop the solution in Java (server side) and JavaScript+JQuery (client side).

EDIT: After examining many XMPP based solutions (many are pretty old and no longer supported), probably I'll go with a XMPP-like custom protocol that covers only the features we need. To develop the solution WebSocket seems to be the most appropriate technology.

The question is, where to start ? I googled but nothings or less about how to use WebSocket with Jetty. Any link? Any resource?

Basically my thought is:

  • A CHAT SERVER based on Jetty Embedded
  • A small front end for the web applications (JQuery) that needs to talk to the server.
  • Communication is based on WebSocket to avoid polling (the real problem)
  • The XMPP-style protocol for XML over WebSocket. But this is not the problem.
  • The problem in how to use WebSocket with a Jetty emdedded custom server and web application.

    ADD As many have pointed out, WebSocket is not well supported for a general purpose usage. Instead AJAX is a more natural solution, but this implies the usage of polling. I've found some example on how to circumvent the problem with long polling, but I was unable to find a rock-solid implementation based on JQuery that was able to:

  • Use WebSocket when available

  • Otherwise, use JQuery-based long polling

  • I think that now the question is more clear. Sorry for my previous 'talk about' style question.


    I have used Atmosphere Framework (https://github.com/Atmosphere/atmosphere). They provide several chat-related samples here: https://github.com/Atmosphere/atmosphere/tree/master/samples


    I would not suggest you to require Websocket for a support system, because there are plenty of people who use Internet Explorer which does not support it yet and likely will never support it on Windows versions previous to Windows 7: http://caniuse.com/websockets

    You said you want to use "Java+JQuery" on the client-side. Are you sure you aren't confusing Java and JavaScript? These technologies have as much in common as Iced Tea and Long Island Iced Tea.

    When you really want to use Java, you needn't use WebSockets, because Java applets can communicate with a server using normal TCP or UDP sockets.

    When you mean JavaScript, I would recommend you to create a solution based on AJAX, because it's much more widely supported and you don't need the real-time performance of WebSockets for a chat application.


    You might want to check out the Fastpath plugins (Service and Webchat) for Openfire. This is an XMPP based solution that is intended to support your use case. It is open source and Java based, so you can easily extend it to suit your purposes.

    There is also support in Smack for Java client based solutions (under the workgroup package).

    链接地址: http://www.djcxy.com/p/94162.html

    上一篇: 正确存储Node.js IM应用程序在MongoDB中的对话

    下一篇: 如何使用带有Jetty emded定制服务器的WebSocket