--- a/runtime/WampClient.py Wed Sep 12 11:36:50 2018 +0200
+++ b/runtime/WampClient.py Tue Oct 02 15:52:11 2018 +0200
@@ -32,13 +32,13 @@
from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS
from autobahn.wamp import types, auth
from autobahn.wamp.serializer import MsgPackSerializer
-from twisted.internet.defer import inlineCallbacks
from twisted.internet.protocol import ReconnectingClientFactory
from twisted.python.components import registerAdapter
from formless import annotate, webform
from nevow import tags, url, static
+from runtime import GetPLCObjectSingleton mandatoryConfigItems = ["ID", "active", "realm", "url"]
@@ -87,7 +87,7 @@
""" Get Callee or Subscriber corresponding to '.' spearated object path """
+ obj = GetPLCObjectSingleton() obj = getattr(obj, names.pop(0))
@@ -115,7 +115,6 @@
"don't know how to handle authmethod {}".format(challenge.method))
def onJoin(self, details):
@@ -128,13 +127,13 @@
print(_("TypeError register option: {}".format(e)))
- yield self.register(GetCallee(name), u'.'.join((ID, name)), registerOptions)
+ self.register(GetCallee(name), u'.'.join((ID, name)), registerOptions) for name in SubscribedEvents:
- yield self.subscribe(GetCallee(name), unicode(name))
+ self.subscribe(GetCallee(name), unicode(name))
print(_('WAMP session joined (%s) by:' % time.ctime()), ID)
@@ -145,6 +144,9 @@
print(_('WAMP session left'))
+ def publishWithOwnID(eventID, value): + ID = self.config.extra["ID"] + self.publish(unicode(ID+'.'+eventID), value) class ReconnectingWampWebSocketClientFactory(WampWebSocketClientFactory, ReconnectingClientFactory):
@@ -341,6 +343,13 @@
+def PublishEvent(eventID, value): + if getWampStatus() == "Attached": + _WampSession.publish(eventID, value) +def PublishEventWithOwnID(eventID, value): + if getWampStatus() == "Attached": + _WampSession.publishWithOwnID(eventID, value) # WEB CONFIGURATION INTERFACE
WAMP_SECRET_URL = "secret"