WebSockets and Java

  • 1,272 views
Uploaded on

A short presentation on WebSockets and their Java server-side usage.

A short presentation on WebSockets and their Java server-side usage.

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,272
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
14
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. WebSocket Bozhidar Bozhanov ...one day at home I decided I'm bored => a WebSocket-based game for http://computoser.com
  • 2. Usecases ● Games ● Stock-exchange application ● ...anything, really
  • 3. Why WebSocket? ● Push ● Real-time communication ● Resource-light ● Intuitive, non-hacky
  • 4. Up to now ● Ajax polling (a.k.a. "are we there yet?") ● Long-polling, streaming ● Plugins – flash/applets/ActiveX ● Problems: hacky, resource-heavy, serverthread-unfriendly
  • 5. WebSocket ● Standard (HTML5) ● TCP, full-duplex ● More effective on the server-side ● High-level protocols ontop – STOMP, WAMP, etc.
  • 6. Client-side ● Standard JavaScript API ● Browser support – problematic ● SockJS, socket.io, fallbacks
  • 7. Server-side ● node.js ● Java – Java EE WebSocket API (JSR-356) ● ● Servlet container implementations – thread pools Spring-MVC API, Spring Messaging API
  • 8. Java WebSocket API vs Spring ● ● Very similar One handler per endpoint, differentiate based on payload ● Out-of-the-box dependency injection with spring ● No annotation configuration in spring (yet)
  • 9. Messaging ● ● Alternative architecture Using a message broker (simple/ActiveMQ/RabbitMQ/..) behind spring ● STOMP over WebSocket ● Client subscribes for events
  • 10. DDD and TDD ● DDD comes naturally ● Objects and their workflows are easily testable ● Very few mocks, comparable to spring-mvc @RequestMappings
  • 11. Security and authentication ● WSS vs WS (ws://example.com/game) ● No same-origin policy. Origin header. ● Validate input and output ● Authentication – cookies? Cookie-like workflow.
  • 12. Conclusion ● It's cool :)