Gateway Event Timer sendMessage not work

我通过button onclick运行system.perspective.sendMessage("mapRefresh",payload = {}, scope = "session") 是成功(is ok)的.

I want Periodic refresh sendMessage刷新数据, 但是在Gateway Event Timer 中运行代码则不成效(inoperative).

不知道是什么原因, 请帮助我一下. 谢谢!

Please post your full code as pre-formatted text.

I suspect one reason your 2nd image code isn't working is because it needs indented one tab. An onClick Mouse Event on a button is a function so at the top there will be:

   #put your code here

where you have done:

#your code is here

You can't use system.perspective.sendMessage() outside of Perspective scripts. Gateway events are outside of Perspective. You must use system.util.sendMessage(...., scope='S') to deliver to a perspective session message handler, which can then relay with system.perspective.sendMessage() to the actual perspective scope you wish to target (if not session).

See this discussion:

谢谢您的回复, 我经过测试不是由于缩进的原因导致的.

谢谢您的帮助, 按照您的提示, 我的问题已经解决了, sendMessage可以正常工作了. 我的解决步骤如下:

  1. Gateway Event -->timer 中sendMessage
  2. Getway Session Event--->Message中 sendMessage.
  3. Vew 中Edit Message Handle接收Recive Message并且执行.

You've put a function in a function. Your def getHostInfo needs indented after def onMessageReceived