]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - server/org.argeo.slc.ria/src/argeo-ria-src/class/org/argeo/ria/remote/RemoteNotifier.js
Use Argeo RIA
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-src / class / org / argeo / ria / remote / RemoteNotifier.js
diff --git a/server/org.argeo.slc.ria/src/argeo-ria-src/class/org/argeo/ria/remote/RemoteNotifier.js b/server/org.argeo.slc.ria/src/argeo-ria-src/class/org/argeo/ria/remote/RemoteNotifier.js
deleted file mode 100644 (file)
index d2cd61d..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/**\r
- * This can be triggered at the end of a IO Request. In that case, it contains\r
- * a data type as an identifier, and the request response itself.\r
- * Can be used this way to listen for data changes from various parts of the application.\r
- */\r
-qx.Class.define("org.argeo.ria.remote.RemoteNotifier",\r
-{\r
-       extend : qx.core.Object,\r
-  \r
-       construct : function(uri, pollService, addService, removeService){\r
-               this.base(arguments);\r
-               this.setUri(uri);\r
-               this.setPollService(pollService);\r
-               this.setAddService(addService);\r
-               this.setRemoveService(removeService);\r
-       },\r
-       properties :{\r
-               uri : {\r
-                       check : "String"                        \r
-               },\r
-               pollService : {check : "String"},\r
-               addService : {check : "String"},\r
-               removeService : {check : "String"},\r
-               eventParamName : {check : "String", init:"eventType"},\r
-               eventXPath : {check : "String", init:"//event"},\r
-               eventTypeXPath : {check : "String", init:"@type"},\r
-               eventDataXPath : {check : "String", init:"@data"},\r
-               answerStatusXPath : {check : "String", init:"execution-answer/status"},\r
-               timeout : {                     \r
-                       init : 20000\r
-               },\r
-               errorTimeout : {\r
-                       init : 5000\r
-               },\r
-               interrupt : {\r
-                       check : "Boolean",\r
-                       init : false\r
-               }\r
-       },\r
-       members : {\r
-               addListener : function(eventType, eventParamName){\r
-                       var req = this._getRequest(this.getAddService());\r
-                       req.setParameter(this.getEventParamName(), eventType);\r
-                       req.send();\r
-               },              \r
-               removeListener : function(eventType, eventParamName){\r
-                       var req = this._getRequest(this.getRemoveService());\r
-                       req.setParameter(this.getEventParamName(), eventType);\r
-                       req.send();\r
-               },\r
-               startPolling : function(){\r
-                       this.setInterrupt(false);\r
-                       var req = this._getRequest(this.getPollService());\r
-                       req.setParameter("timeout", "10");\r
-                       req.addListener("completed", this._pollHandler, this);\r
-                       req.send();                     \r
-               },\r
-               stopPolling : function(){\r
-                       this.setInterrupt(true);\r
-               },\r
-               _poll : function(){\r
-                       if(this.getInterrupt()) return;\r
-                       var req = this._getRequest(this.getPollService());\r
-                       req.setParameter("timeout", this.getTimeout());\r
-                       req.setTimeout(this.getTimeout() + 5000);\r
-                       req.addListener("completed", this._pollHandler, this);\r
-                       req.addListener("failed", this._errorHandler, this);\r
-                       req.addListener("timeout", this._errorHandler, this);\r
-                       req.addListener("aborted", this._errorHandler, this);\r
-                       req.send();\r
-               },\r
-               _pollHandler : function(response){\r
-                       // Parse response\r
-                       var status = org.argeo.ria.util.Element.getSingleNodeText(response.getContent(), this.getAnswerStatusXPath());\r
-                       if(status && status == "ERROR"){\r
-                               this._errorHandler();\r
-                               return;\r
-                       }\r
-                       var messages = org.argeo.ria.util.Element.selectNodes(response.getContent(), this.getEventXPath());\r
-                       if(messages){\r
-                               for(var i=0;i<messages.length;i++){\r
-                                       try{\r
-                                               var eventType = org.argeo.ria.util.Element.getSingleNodeText(messages[i], this.getEventTypeXPath());\r
-                                               var eventData = org.argeo.ria.util.Element.getSingleNodeText(messages[i], this.getEventDataXPath());\r
-                                               org.argeo.ria.event.UIBus.getInstance().dispatchEvent(eventType, eventData);\r
-                                       }catch(e){\r
-                                               this.error(e);\r
-                                       }\r
-                               }\r
-                       }\r
-                       this._poll();\r
-               },\r
-               _errorHandler : function(){\r
-                       // Wait an try again later\r
-                       qx.event.Timer.once(this._poll, this, this.getErrorTimeout());\r
-               },\r
-               _getRequest : function(service, method, type){\r
-                       return new qx.io.remote.Request(\r
-                               this.getUri()+service, \r
-                               method || "GET", \r
-                               type||"application/xml"\r
-                       );\r
-               }\r
-       }\r
-});
\ No newline at end of file