mirror of
https://github.com/fergalmoran/dss.git
synced 2026-01-01 06:28:39 +00:00
56 lines
2.0 KiB
JavaScript
56 lines
2.0 KiB
JavaScript
// Generated by CoffeeScript 1.4.0
|
|
(function() {
|
|
|
|
define(['vent', 'socket.io'], function(vent, SocketIO) {
|
|
var RealtimeController;
|
|
RealtimeController = (function() {
|
|
|
|
function RealtimeController() {}
|
|
|
|
RealtimeController.prototype.startSocketIO = function() {
|
|
var _this = this;
|
|
console.log("RealtimeController: SocketIO starting on " + com.podnoms.settings.REALTIME_HOST);
|
|
this.socket = SocketIO.connect(com.podnoms.settings.REALTIME_HOST);
|
|
this.socket.on("connect", function() {
|
|
return console.log("RealtimeController: Socket connected");
|
|
});
|
|
this.socket.on("message", function(message) {
|
|
return alert(message);
|
|
});
|
|
this.socket.on("server-session", function(session) {
|
|
var sessionId;
|
|
if (session) {
|
|
console.log("RealtimeController: Connected " + sessionId);
|
|
sessionId = session['sessionId'];
|
|
return _this.registerSessionWithServer(sessionId);
|
|
} else {
|
|
return console.log("RealtimeController: Can't read sessionId from socket");
|
|
}
|
|
});
|
|
this.socket.on("activity", function(data) {
|
|
console.log("RealtimeController: activity " + data['message']);
|
|
return vent.trigger("model:activity:new", data['message']);
|
|
});
|
|
return this.socket.on("notification", function(data) {
|
|
console.log("RealtimeController: notification " + data['message']);
|
|
return vent.trigger("model:notification:new", data['message']);
|
|
});
|
|
};
|
|
|
|
RealtimeController.prototype.registerSessionWithServer = function(sessionId) {
|
|
return console.log("Registering session: " + sessionId);
|
|
};
|
|
|
|
RealtimeController.prototype.sendMessage = function(message) {
|
|
console.log("RealtimeController: sendMessage");
|
|
return console.log(message);
|
|
};
|
|
|
|
return RealtimeController;
|
|
|
|
})();
|
|
return RealtimeController;
|
|
});
|
|
|
|
}).call(this);
|