I'm trying to get a WebSocket server application working using Glassfish 3.1.
There is very little information about how to do it since both Glassfish 3.1 and WebSocket are not finished yet. The best source I've found so far is Antwerkz, Inc. which like this post got out-of-date pretty quickly.
I'll try to publish here the things I did manage to get working hope it will help other in the way.
I'm currently using Glassfish 3.1 nightly build (glassfish-3.1-b07-06_27_2010) and NetBeans 6.8 development release (201006130001). I'm working on Windows XP Pro machine.
I've copy the following files from glassfish\modules into my project\lib:
Those files needed because I use classes from them in my project code.
Another important thing (and easy to forget) is to turn on web socket support in grizzly by running this command:
I've used a servlet to register my WebSocket application.
This is the code for the servlet:
In order for this servlet will actually get initialized we have to change web.xml file in WEB-INF:
Now we left with implement ChatApplication and ChatWebSocket which I will cover once I'll actually get them to work.
The things I can't understand yet:
- How is responsible to set isConnected on the socket? is it me or the framework?
- How to broadcast message to several (all or part) sockets without suffer from delay due to closed or unresponsive sockets?
Hope it helps,