开发者

GlassFish, Java, Grizzly, WebSockets - how to get started?

I am faced with the necessity to push some messages to the clients of my web-application in Java. After some reading up on the subject, i decided to use websockets as an emerging and a promicing technology, and to use GlassFish as the server. However, all the examples i find are either quite complicated or outdated and do not compile with Grizzly 2.

Is there a really simple example with j开发者_开发知识库ust a few lines of code that would push something like "hello, world" to the client?

Thanks in advance, Timofey.


I know what you mean. I've been working on a response to this. You might also be interesting in beginning with websockets comment here. Please read those responses. They might help get you started. The current downloadable javascript code from the suggested demo is intended to provide some flexibility and nice features for testing - although if you download it and look into WSTest.htm, it's really not so complicated. Might be just what you're looking for. Then maybe we can all get together and work things out with grizzly.

UPDATE: As I work through grizzly myself, I found on the Quick Start in the glassfish admin console, there's a hello sample that's pretty easy to set up and run. You'll find instructions there. The sample directory also contains a war file named: websocket-mozilla; so I guess its supposed to use websockets. Someone who's familiar with jsp should review the source code. All I can see is that it's using an http session. No mention of a websocket at all. It's a lot like the hello sample.


I use CometD implementation on GlassFish. It has different transport protocols including Websockets (although they don't recommend it yet). See my answer to another related question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜