Knoldus Software LLP

Using WebSockets In Play!

Neelkanth Sachdeva
Software Consultant

neelkanthsachdeva.wordpress.com
Agenda
Short Polling
Long Polling
WebSockets
Websockets with Play !
The Play Chat Application Using Wesockets
Short Polling

Drawbacks :
Resource Intensive
Slow Even Very Slow
One Request / One Response
Long Polling

Drawbacks :
- Half Duplax
- Again one request / one response
Whats our probelm

Lots of incoming messages
Websockets
WebSocket Features & Limitations
Features :
Full duplax communication
Real time messages
Efficient & Fast
Drawbacks :
Avai...
Using Websockets with Play !

Producer

Consumer
Using Websockets with Play !

Producer
Enumerator

Consumer
Iteratee
Iteratees
The Consumer
Consumes chunks from Producer
Enumerator
The Producer
- Produces typed chunks
- Only produces if consumer is there.
At Server :
Creating a websocket connection needs a
Producer (Enumerator) & a Consumer
(Iteratee)
At Client :
Creating a socket connection.
var socket = new WebSocket(“ws://localhost:9000”)

The Events
- onmessage
- onop...
Understand it through play sample chat
application available here :
https://github.com/playframework/playframework/tree/ma...
Cheers !
Upcoming SlideShare
Loading in …5
×

Using Websockets in Play !

2,563 views

Published on

Using Websockets in Play !

Using Websockets in Play !

  1. 1. Knoldus Software LLP Using WebSockets In Play! Neelkanth Sachdeva Software Consultant neelkanthsachdeva.wordpress.com
  2. 2. Agenda Short Polling Long Polling WebSockets Websockets with Play ! The Play Chat Application Using Wesockets
  3. 3. Short Polling Drawbacks : Resource Intensive Slow Even Very Slow One Request / One Response
  4. 4. Long Polling Drawbacks : - Half Duplax - Again one request / one response
  5. 5. Whats our probelm Lots of incoming messages
  6. 6. Websockets
  7. 7. WebSocket Features & Limitations Features : Full duplax communication Real time messages Efficient & Fast Drawbacks : Available with newer browsers
  8. 8. Using Websockets with Play ! Producer Consumer
  9. 9. Using Websockets with Play ! Producer Enumerator Consumer Iteratee
  10. 10. Iteratees The Consumer Consumes chunks from Producer
  11. 11. Enumerator The Producer - Produces typed chunks - Only produces if consumer is there.
  12. 12. At Server : Creating a websocket connection needs a Producer (Enumerator) & a Consumer (Iteratee)
  13. 13. At Client : Creating a socket connection. var socket = new WebSocket(“ws://localhost:9000”) The Events - onmessage - onopen - onclose
  14. 14. Understand it through play sample chat application available here : https://github.com/playframework/playframework/tree/master/samples/scala/websocket-chat
  15. 15. Cheers !

×