cleanup
This commit is contained in:
		@@ -321,14 +321,14 @@ class ApplicationSession(BaseSession):
 | 
			
		||||
      """
 | 
			
		||||
      Implements :func:`autobahn.wamp.interfaces.ISession.onConnect`
 | 
			
		||||
      """
 | 
			
		||||
      self.join(six.u(self.config.realm))
 | 
			
		||||
      self.join(self.config.realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def join(self, realm):
 | 
			
		||||
      """
 | 
			
		||||
      Implements :func:`autobahn.wamp.interfaces.ISession.join`
 | 
			
		||||
      """
 | 
			
		||||
      if True or six.PY2 and type(realm) == str:
 | 
			
		||||
      if six.PY2 and type(realm) == str:
 | 
			
		||||
         realm = six.u(realm)
 | 
			
		||||
 | 
			
		||||
      if self._session_id:
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,10 @@ import six
 | 
			
		||||
 | 
			
		||||
class ComponentConfig:
 | 
			
		||||
   def __init__(self, realm = None, extra = None):
 | 
			
		||||
      if six.PY2 and type(realm) == str:
 | 
			
		||||
         self.realm = six.u(realm)
 | 
			
		||||
      else:
 | 
			
		||||
         self.realm = realm
 | 
			
		||||
      self.extra = extra
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -125,7 +128,9 @@ class SubscribeOptions:
 | 
			
		||||
      assert(details_arg is None or type(details_arg) == str)
 | 
			
		||||
 | 
			
		||||
      self.details_arg = details_arg
 | 
			
		||||
      self.options = {'match': six.u(match)}
 | 
			
		||||
      if match and six.PY2 and type(match) == str:
 | 
			
		||||
         match = six.u(match)
 | 
			
		||||
      self.options = {'match': match}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -207,7 +212,6 @@ class RegisterOptions:
 | 
			
		||||
                          in this keyword argument to the callable.
 | 
			
		||||
      :type details_arg: str
 | 
			
		||||
      """
 | 
			
		||||
      assert(details_arg is None or type(details_arg) == six.text_type)
 | 
			
		||||
      self.details_arg = details_arg
 | 
			
		||||
      self.options = {
 | 
			
		||||
         'pkeys': pkeys,
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,9 @@ if __name__ == '__main__':
 | 
			
		||||
   parser.add_argument("-c", "--component", type = str,
 | 
			
		||||
                       help = "Start WAMP client with this application component, e.g. 'timeservice.TimeServiceFrontend'")
 | 
			
		||||
 | 
			
		||||
   parser.add_argument("-r", "--realm", type = str, default = "realm1",
 | 
			
		||||
                       help = "The WAMP realm to start the component in (if any).")
 | 
			
		||||
 | 
			
		||||
   parser.add_argument("--host", type = str, default = "127.0.0.1",
 | 
			
		||||
                       help = 'IP or hostname to connect to.')
 | 
			
		||||
 | 
			
		||||
@@ -51,7 +54,7 @@ if __name__ == '__main__':
 | 
			
		||||
   ##
 | 
			
		||||
   from autobahn.asyncio.wamp import ApplicationSessionFactory
 | 
			
		||||
   from autobahn.wamp import types
 | 
			
		||||
   session_factory = ApplicationSessionFactory(types.ComponentConfig(realm = u"realm1"))
 | 
			
		||||
   session_factory = ApplicationSessionFactory(types.ComponentConfig(realm = args.realm))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   ## dynamically load the application component ..
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ class Component(ApplicationSession):
 | 
			
		||||
         print("{}: {} in {}".format(msg, res, duration))
 | 
			
		||||
 | 
			
		||||
      t1 = time.clock()
 | 
			
		||||
      d1 = self.call('com.math.slowsquare', 3)
 | 
			
		||||
      d1 = self.call('com.math.slowsquare', 3, 2)
 | 
			
		||||
      d1.add_done_callback(partial(got, t1, "Slow Square"))
 | 
			
		||||
 | 
			
		||||
      t2 = time.clock()
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,9 @@ if __name__ == '__main__':
 | 
			
		||||
   parser.add_argument("-c", "--component", type = str, default = None,
 | 
			
		||||
                       help = "Start WAMP server with this application component, e.g. 'timeservice.TimeServiceBackend', or None.")
 | 
			
		||||
 | 
			
		||||
   parser.add_argument("-r", "--realm", type = str, default = "realm1",
 | 
			
		||||
                       help = "The WAMP realm to start the component in (if any).")
 | 
			
		||||
 | 
			
		||||
   parser.add_argument("--interface", type = str, default = "127.0.0.1",
 | 
			
		||||
                       help = 'IP of interface to listen on.')
 | 
			
		||||
 | 
			
		||||
@@ -71,7 +74,7 @@ if __name__ == '__main__':
 | 
			
		||||
      ## run next to the router
 | 
			
		||||
      ##
 | 
			
		||||
      from autobahn.wamp import types
 | 
			
		||||
      session_factory.add(SessionKlass(types.ComponentConfig(realm = u"realm1")))
 | 
			
		||||
      session_factory.add(SessionKlass(types.ComponentConfig(realm = args.realm)))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   if args.transport == "websocket":
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,9 @@ if __name__ == '__main__':
 | 
			
		||||
   parser.add_argument("-c", "--component", type = str,
 | 
			
		||||
                       help = "Start WAMP client with this application component, e.g. 'timeservice.TimeServiceFrontend'")
 | 
			
		||||
 | 
			
		||||
   parser.add_argument("-r", "--realm", type = str, default = "realm1",
 | 
			
		||||
                       help = "The WAMP realm to start the component in (if any).")
 | 
			
		||||
 | 
			
		||||
   parser.add_argument("--endpoint", type = str, default = "tcp:127.0.0.1:8080",
 | 
			
		||||
                       help = 'Twisted client endpoint descriptor, e.g. "tcp:127.0.0.1:8080" or "unix:/tmp/mywebsocket".')
 | 
			
		||||
 | 
			
		||||
@@ -64,7 +67,8 @@ if __name__ == '__main__':
 | 
			
		||||
   ## create a WAMP application session factory
 | 
			
		||||
   ##
 | 
			
		||||
   from autobahn.twisted.wamp import ApplicationSessionFactory
 | 
			
		||||
   session_factory = ApplicationSessionFactory()
 | 
			
		||||
   from autobahn.wamp import types
 | 
			
		||||
   session_factory = ApplicationSessionFactory(types.ComponentConfig(realm = args.realm))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   ## dynamically load the application component ..
 | 
			
		||||
 
 | 
			
		||||
@@ -29,15 +29,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component that publishes an event every second.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
      counter = 0
 | 
			
		||||
 
 | 
			
		||||
@@ -29,10 +29,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   and stop after having received 5 events.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -47,9 +43,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      yield self.subscribe(on_event, 'com.myapp.topic1')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -33,15 +33,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   and with complex payloads every second.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -33,10 +33,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   of no payload and of complex payload, and stops after 5 seconds.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -57,9 +53,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      reactor.callLater(5, self.leave)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -29,15 +29,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component that publishes an event every second.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
      counter = 0
 | 
			
		||||
 
 | 
			
		||||
@@ -30,16 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   and stop after having received 5 events.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
      self.received = 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -69,9 +59,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      print("Got event on topic2: {}".format(msg))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -30,15 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component that publishes an event every second.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -31,10 +31,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   and stop after having received 5 events.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -50,9 +46,5 @@ class Component(ApplicationSession):
 | 
			
		||||
                              options = SubscribeOptions(details_arg = 'details'))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -29,15 +29,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component that publishes an event every second.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -53,10 +53,6 @@ class Component(ApplicationSession):
 | 
			
		||||
      print("Subscribed with subscription ID {}".format(self.subscription.id))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -64,9 +60,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      yield self.test()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -28,10 +28,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component providing procedures with different kinds of arguments.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(u"realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
      def ping():
 | 
			
		||||
 
 | 
			
		||||
@@ -28,10 +28,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component calling the different backend procedures.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(u"realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -74,9 +70,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      self.leave()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -30,15 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   return complex results.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
      def add_complex(a, ai, b, bi):
 | 
			
		||||
 
 | 
			
		||||
@@ -30,10 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   produce complex results and showing how to access those.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -46,9 +42,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      self.leave()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -30,17 +30,9 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component registering RPC endpoints using decorators.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
      print("273423")
 | 
			
		||||
 | 
			
		||||
      ## register all methods on this object decorated with "@wamp.procedure"
 | 
			
		||||
      ## as a RPC endpoint
 | 
			
		||||
 
 | 
			
		||||
@@ -28,21 +28,13 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component calling the different backend procedures.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
      print("SDFJSDLF")
 | 
			
		||||
 | 
			
		||||
      procs = ['com.mathservice.add2',
 | 
			
		||||
               'com.mathservice.mul2',
 | 
			
		||||
               'com.mathservice.div2']
 | 
			
		||||
      procs = [u'com.mathservice.add2',
 | 
			
		||||
               u'com.mathservice.mul2',
 | 
			
		||||
               u'com.mathservice.div2']
 | 
			
		||||
 | 
			
		||||
      try:
 | 
			
		||||
         for proc in procs:
 | 
			
		||||
@@ -54,9 +46,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      self.leave()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -41,15 +41,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   Example WAMP application backend that raised exceptions.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
      ## raising standard exceptions
 | 
			
		||||
 
 | 
			
		||||
@@ -41,10 +41,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   Example WAMP application frontend that catches exceptions.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -83,9 +79,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      self.leave()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -30,15 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   different kinds of arguments.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
      def square(val, details = None):
 | 
			
		||||
 
 | 
			
		||||
@@ -29,10 +29,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component calling the different backend procedures.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -48,9 +44,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      self.leave()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -30,14 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   Application component that produces progressive results.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -30,10 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   Application component that consumes progressive results.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
@@ -47,9 +43,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      self.leave()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -30,15 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   A math service application component.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
      def square(x):
 | 
			
		||||
 
 | 
			
		||||
@@ -30,10 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component using the time service.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
      def got(res, started, msg):
 | 
			
		||||
@@ -55,9 +51,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      DeferredList ([d1, d2]).addBoth(done)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   A simple time service application component.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
      def utcnow():
 | 
			
		||||
 
 | 
			
		||||
@@ -30,10 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   An application component using the time service.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
      try:
 | 
			
		||||
@@ -46,9 +42,5 @@ class Component(ApplicationSession):
 | 
			
		||||
      self.leave()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onLeave(self, details):
 | 
			
		||||
      self.disconnect()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onDisconnect(self):
 | 
			
		||||
      reactor.stop()
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,9 @@ if __name__ == '__main__':
 | 
			
		||||
   parser.add_argument("-c", "--component", type = str, default = None,
 | 
			
		||||
                       help = "Start WAMP server with this application component, e.g. 'timeservice.TimeServiceBackend', or None.")
 | 
			
		||||
 | 
			
		||||
   parser.add_argument("-r", "--realm", type = str, default = "realm1",
 | 
			
		||||
                       help = "The WAMP realm to start the component in (if any).")
 | 
			
		||||
 | 
			
		||||
   parser.add_argument("--endpoint", type = str, default = "tcp:8080",
 | 
			
		||||
                       help = 'Twisted server endpoint descriptor, e.g. "tcp:8080" or "unix:/tmp/mywebsocket".')
 | 
			
		||||
 | 
			
		||||
@@ -84,7 +87,8 @@ if __name__ == '__main__':
 | 
			
		||||
      ## .. and create and add an WAMP application session to
 | 
			
		||||
      ## run next to the router
 | 
			
		||||
      ##
 | 
			
		||||
      session_factory.add(SessionKlass())
 | 
			
		||||
      from autobahn.wamp import types
 | 
			
		||||
      session_factory.add(SessionKlass(types.ComponentConfig(realm = args.realm)))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   if args.transport == "websocket":
 | 
			
		||||
 
 | 
			
		||||
@@ -26,13 +26,6 @@ from autobahn.twisted.wamp import ApplicationSession
 | 
			
		||||
 | 
			
		||||
class MyAppComponent(ApplicationSession):
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
      if not self.factory._myAppSession:
 | 
			
		||||
         self.factory._myAppSession = self
 | 
			
		||||
 
 | 
			
		||||
@@ -30,15 +30,6 @@ class Component(ApplicationSession):
 | 
			
		||||
   A simple time service application component.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self, realm = "realm1"):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
      self._realm = realm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      self.join(self._realm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
 | 
			
		||||
      def utcnow():
 | 
			
		||||
 
 | 
			
		||||
@@ -31,17 +31,11 @@ class Component(ApplicationSession):
 | 
			
		||||
   during 3 subsequent WAMP sessions, while the
 | 
			
		||||
   underlying transport continues to exist.
 | 
			
		||||
   """
 | 
			
		||||
 | 
			
		||||
   def __init__(self):
 | 
			
		||||
      ApplicationSession.__init__(self)
 | 
			
		||||
   def __init__(self, config):
 | 
			
		||||
      ApplicationSession.__init__(self, config)
 | 
			
		||||
      self.count = 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   def onConnect(self):
 | 
			
		||||
      print("Transport connected.")
 | 
			
		||||
      self.join("realm1")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   @inlineCallbacks
 | 
			
		||||
   def onJoin(self, details):
 | 
			
		||||
      print("Realm joined (WAMP session started).")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user