I want to implement an application based on Scala and Play! 2.1 where all data transport is handled through websockets in real-time. Since the application supports collaboration of several users, I want to be able to call methods on a) the server, b) one client, c) all clients.
For example, let's say there are Users Bob, Jane and Carl.
Carl creates a "note" which is sent through the socket and then, if successfully stored, added to the DOM through basic Javascript (let's say addNote(note)
) on all clients.
A sample call could look like this:
// sends message type createCard to server, takes <form id="card"> as data and receives a JSON object as response
mysocket.send("createCard", $('#card').serialize(), { success: function(data) {
var card = data.card
mysocket.allClients().addCard(card); // appends <div id="card"> to DOM
});
Is this possible or am I going about this the wrong way entirely?
See SignalJ - a port of SignalR ideas to PlayFramework and Akka.