mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-22 17:48:51 +00:00
49 lines
1.8 KiB
JavaScript
49 lines
1.8 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() {
|
|
var _this = this;
|
|
console.log("RealtimeController: Socket connected");
|
|
this.socket.emit('client-reg', {
|
|
sessionId: com.podnoms.settings.currentUser,
|
|
userName: com.podnoms.settings.userName
|
|
});
|
|
return this.socket.on("server-session", function(data) {
|
|
if (data) {
|
|
return console.log("RealtimeController: Connected " + data['sessionId']);
|
|
} else {
|
|
return console.log("RealtimeController: Can't read sessionId from socket");
|
|
}
|
|
});
|
|
});
|
|
"@socket.on \"activity\", (data) =>\n console.log(\"RealtimeController: activity \" + data['message'])\n 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.sendMessage = function(message) {
|
|
console.log("RealtimeController: sendMessage");
|
|
return console.log(message);
|
|
};
|
|
|
|
return RealtimeController;
|
|
|
|
})();
|
|
return RealtimeController;
|
|
});
|
|
|
|
}).call(this);
|