Index: js/class.cmessages.js
===================================================================
--- js/class.cmessages.js	(revision 89840)
+++ js/class.cmessages.js	(working copy)
@@ -69,6 +69,51 @@
 		});
 	},
 
+    syncRemove: function(uid) {
+        var u = localStorage.getItem('zbx')
+        if (u) {
+            u = JSON.parse(u)
+        } else {
+            u = {}
+        }
+        delete u[uid]
+        localStorage.setItem('zbx', JSON.stringify(u))
+    },
+
+    syncAdd: function(m) {
+        var u = localStorage.getItem('zbx')
+        if (u) {
+            u = JSON.parse(u)
+        } else {
+            u = {}
+        }
+        u[m.uid] = m
+        localStorage.setItem('zbx', JSON.stringify(u))
+    },
+
+    sync: function(mm) {
+        var obj = Object.keys(this.messageList)
+        var a = Object.keys(mm)
+        var toremove = [];
+
+        jQuery.each(mm, function (uid, m) {
+            this.addMessage(m)
+        }.bind(this))
+
+        obj.forEach(function (uid) {
+            if (a.indexOf(uid) === -1) {
+                this.closeMessage(this.messageList[uid])
+            }
+        }.bind(this));
+    },
+
+    shared: function() {
+        var u = localStorage.getItem('zbx')
+        if (u) {
+            this.sync(JSON.parse(u))
+        }
+    },
+
 	start: function() {
 		this.stop();
 
@@ -83,6 +128,11 @@
 			this.PEtimeout = new PeriodicalExecuter(this.timeoutMessages.bind(this), this.timeoutFrequency);
 			this.timeoutMessages();
 		}
+
+		if ("to run shared?") {
+			new PeriodicalExecuter(this.shared.bind(this), 5);
+			this.shared();
+		}
 	},
 
 	stop: function() {
@@ -124,6 +174,11 @@
 	},
 
 	addMessage: function(newMessage) {
+        this.syncAdd(newMessage)
+        if (this.messageList[newMessage.uid]) {
+            return;
+        }
+
 		newMessage = newMessage || {};
 
 		while (isset(this.msgcounter, this.messageList)) {
@@ -135,15 +190,17 @@
 			this.closeMessage(lastMessageId);
 		}
 
-		this.messagePipe.push(this.msgcounter);
+		// this.messagePipe.push(this.msgcounter);
+		this.messagePipe.push(newMessage.uid);
 		newMessage.messageid = this.msgcounter;
+		newMessage.messageid = newMessage.uid;
 
-		this.messageList[this.msgcounter] = new CMessage(this, newMessage);
-		this.messageLast[this.messageList[this.msgcounter].caption] = {
-			'caption': this.messageList[this.msgcounter].caption,
-			'sourceid': this.messageList[this.msgcounter].sourceid,
-			'time': this.messageList[this.msgcounter].time,
-			'messageid': this.messageList[this.msgcounter].messageid
+		this.messageList[newMessage.messageid] = new CMessage(this, newMessage);
+		this.messageLast[this.messageList[newMessage.messageid].caption] = {
+			'caption': this.messageList[newMessage.messageid].caption,
+			'sourceid': this.messageList[newMessage.messageid].sourceid,
+			'time': this.messageList[newMessage.messageid].time,
+			'messageid': this.messageList[newMessage.messageid].messageid
 		};
 
 		var trigger_element = document.activeElement;
@@ -152,7 +209,7 @@
 			overlayDialogueOnLoad(true, this);
 		});
 
-		return this.messageList[this.msgcounter];
+		return this.messageList[newMessage.messageid];
 	},
 
 	snooze: function(e) {
@@ -250,6 +307,7 @@
 	},
 
 	closeMessage: function(messageid, withEffect) {
+        this.syncRemove(messageid)
 		if (!isset(messageid, this.messageList)) {
 			return true;
 		}
Index: jsrpc.php
===================================================================
--- jsrpc.php	(revision 89840)
+++ jsrpc.php	(working copy)
@@ -105,6 +105,8 @@
 			'priority' => array_keys($msgsettings['triggers.severities']),
 			'triggerLimit' => 15
 		];
+		/* $options['lastChangeSince'] = '2'; */
+		 
 		if (!$msgsettings['triggers.recovery']) {
 			$options['value'] = [TRIGGER_VALUE_TRUE];
 		}
@@ -147,6 +149,7 @@
 					$url_tr_events = 'tr_events.php?eventid='.$event['eventid'].'&triggerid='.$event['objectid'];
 
 					$result[$number] = [
+						'uid' => $event['eventid'] . $event['clock'],
 						'type' => 3,
 						'caption' => 'events',
 						'sourceid' => $event['eventid'],
