Built motion from commit 5e31ea4.|0.0.32
[motion.git] / server / api / report_mail_session / report_mail_session.socket.js
index ae445aa..6489a0d 100644 (file)
@@ -1 +1,27 @@
-var _0x396d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0x396d[0];var ReportMailSession=require(_0x396d[2])[_0x396d[1]];exports[_0x396d[3]]=function(_0xcda0x2){ReportMailSession[_0x396d[4]](function(_0xcda0x3){onSave(_0xcda0x2,_0xcda0x3)});ReportMailSession[_0x396d[5]](function(_0xcda0x3){onSave(_0xcda0x2,_0xcda0x3)});ReportMailSession[_0x396d[6]](function(_0xcda0x3){onRemove(_0xcda0x2,_0xcda0x3)});};function onSave(_0xcda0x2,_0xcda0x3,_0xcda0x5){_0xcda0x2[_0x396d[8]](_0x396d[7],_0xcda0x3)}function onRemove(_0xcda0x2,_0xcda0x3,_0xcda0x5){_0xcda0x2[_0x396d[8]](_0x396d[9],_0xcda0x3)}
\ No newline at end of file
+/**
+ * Broadcast updates to client when the model changes
+ */
+
+'use strict';
+
+var ReportMailSession = require('../../models').ReportMailSession;
+
+exports.register = function(socket) {
+  ReportMailSession.afterCreate(function(doc) {
+    onSave(socket, doc);
+  });
+  ReportMailSession.afterUpdate(function(doc) {
+    onSave(socket, doc);
+  });
+  ReportMailSession.afterDestroy(function(doc) {
+    onRemove(socket, doc);
+  });
+}
+
+function onSave(socket, doc, cb) {
+  socket.emit('report_mail_session:save', doc);
+}
+
+function onRemove(socket, doc, cb) {
+  socket.emit('report_mail_session:remove', doc);
+}