Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Playtosphere: Atmosphere for Play!

This project brings the Atmosphere Framework to the Play! Framework. It support ALL Atmosphere's modules like Runtime, Jersey and Socket.IO.

Try it!

Fork the samples workspace and go under samples/chat or samples/jersey)

   % sbt update
   % sbt run

Download Atmosphere Play!, use Maven or sbt

For Play 2.6.x+:


For Play 2.5.x+:


For Play 2.4.x+:


For Play 2.2.x+:


For Play 2.1.x:


Join the growing community

If you are interested, subscribe to our mailing list for more info! We are on under #atmosphere-comet

WebSockets, Server Sent Events, Streaming and Long-Polling transparently supported!

Server side using atmosphere-runtime

@ManagedService(path = "/chat")
public class Chat {
    private final Logger logger = LoggerFactory.getLogger(Chat.class);

     * Invoked when the connection as been fully established and suspended, e.g ready for receiving messages.
     * @param r
    public void onReady(final AtmosphereResource r) {"Browser {} connected.", r.uuid());

     * Invoked when the client disconnect or when an unexpected closing of the underlying connection happens.
     * @param event
    public void onDisconnect(AtmosphereResourceEvent event) {
        if (event.isCancelled()) {
  "Browser {} unexpectedly disconnected", event.getResource().uuid());
        } else if (event.isClosedByClient()) {
  "Browser {} closed the connection", event.getResource().uuid());

     * Simple annotated class that demonstrate how {@link org.atmosphere.config.managed.Encoder} and {@link org.atmosphere.config.managed.Decoder
     * can be used.
     * @param message an instance of {@link Message}
     * @return
     * @throws IOException
    @org.atmosphere.config.service.Message(encoders = {JacksonEncoder.class}, decoders = {JacksonDecoder.class})
    public Message onMessage(Message message) throws IOException {"{} just send {}", message.getAuthor(), message.getMessage());
        return message;

Server side using atmosphere-jersey

 public class ChatResource {

      * Suspend the response without writing anything back to the client.
      * @return a white space
     @Suspend(contentType = "application/json")
     public String suspend() {
         return "";

      * Broadcast the received message object to all suspended response. Do not write back the message to the calling connection.
      * @param message a {@link Message}
      * @return a {@link Response}
     @Broadcast(writeEntity = false)
     public Response broadcast(Message message) {
         return new Response(message.getAuthor(), message.getMessage());

and on the client side,

    $(function () {
        "use strict";

        var header = $('#header');
        var content = $('#content');
        var input = $('#input');
        var status = $('#status');
        var myName = false;
        var author = null;
        var logged = false;
        var socket = $.atmosphere;
        var subSocket;
        var transport = 'websocket';

        // We are now ready to cut the request
        var request = { url: document.location.toString() + 'chat',
            contentType : "application/json",
            logLevel : 'debug',
            transport : transport ,
            trackMessageLength : true,
            fallbackTransport: 'websocket'};

        request.onMessage = function (response) {

             // do something

        request.onClose = function(response) {

        request.onError = function(response) {

        subSocket = socket.subscribe(request);



Atmosphere Framework for Play!



No packages published
You can’t perform that action at this time.