runtime/WampClient.py
branch#2486
changeset 2196 9017e830ae70
parent 2195 2cef75d036c2
child 2197 bec80ff35282
--- a/runtime/WampClient.py	Mon Apr 09 14:38:38 2018 +0200
+++ b/runtime/WampClient.py	Tue Apr 10 09:54:22 2018 +0200
@@ -70,6 +70,15 @@
         obj = getattr(obj, names.pop(0))
     return obj
 
+def getValidOptins(options, arguments):
+    validOptions = {}
+    for key in options:
+        if key in arguments:
+            validOptions[key] = options[key]
+    if len(validOptions) > 0:
+        return validOptions
+    else:
+        return None
 
 class WampSession(wamp.ApplicationSession):
     def onConnect(self):
@@ -92,8 +101,16 @@
         global _WampSession
         _WampSession = self
         ID = self.config.extra["ID"]
+        regoption = None
+
+        registerOptions = self.config.extra.get('registerOptions', None)
+        arguments = inspect.getargspec(types.RegisterOptions.__init__).args
+        validRegisterOptions = getValidOptins(registerOptions, arguments)
+        if validRegisterOptions:
+            regoption = types.RegisterOptions(**validRegisterOptions)
+            #print(_("Added custom register options"))
+
         for name in ExposedCalls:
-            regoption = types.RegisterOptions(u'exact', u'last')
             yield self.register(GetCallee(name), u'.'.join((ID, name)), regoption)
 
         for name in SubscribedEvents:
@@ -114,21 +131,12 @@
     def __init__(self, config, *args, **kwargs):
         WampWebSocketClientFactory.__init__(self, *args, **kwargs)
 
+        protocolOptions = config.extra.get('protocolOptions', None)
         arguments = inspect.getargspec(self.setProtocolOptions).args
-        protocolOptions = config.extra.get('protocolOptions', None)
-
-        validProtocolOptions = {}
-
-        for key in protocolOptions:
-            if key in arguments:
-                validProtocolOptions[key] = protocolOptions[key]
-
-        if len(validProtocolOptions) > 0:
+        validProtocolOptions = getValidOptins(protocolOptions, arguments)
+        if validProtocolOptions:
             self.setProtocolOptions(**validProtocolOptions)
-            print(_("Added custom protocol options"))
-
-        del validProtocolOptions
-        del protocolOptions
+            #print(_("Added custom protocol options"))
 
     def buildProtocol(self, addr):
         self.resetDelay()